private JObject GetListener(OutputListener listener)
{
var res = new JObject();
res["listenerId"] = GetObjectId(listener);
res["address"] = listener.LocalEndPoint.Address.ToString();
res["port"] = listener.LocalEndPoint.Port;
res["localAccepts"] = (int)listener.LocalOutputAccepts;
res["globalAccepts"] = (int)listener.GlobalOutputAccepts;
res["localAuthorizationRequired"] = listener.LocalAuthorizationRequired;
res["globalAuthorizationRequired"] = listener.GlobalAuthorizationRequired;
res["authenticationId"] = listener.AuthenticationKey!=null ? listener.AuthenticationKey.Id : null;
res["authenticationPassword"] = listener.AuthenticationKey!=null ? listener.AuthenticationKey.Password : null;
res["authToken"] = listener.AuthenticationKey!=null ? HTTPUtils.CreateAuthorizationToken(listener.AuthenticationKey) : null;
if ((listener.GlobalOutputAccepts & OutputStreamType.Relay)!=0 && owner.OpenedPorts!=null) {
res["isOpened"] = (listener.GlobalOutputAccepts & OutputStreamType.Relay)!=0 &&
owner.OpenedPorts.Contains(listener.LocalEndPoint.Port);
}
else {
res["isOpened"] = null;
}
return res;
}