mirror of
https://github.com/sochix/TLSharp.git
synced 2025-12-06 08:02:00 +01:00
Added constructor option to toggle usage of IPv6 datacenter addresses.
This commit is contained in:
parent
4a663d89b3
commit
cb64fb61e6
|
|
@ -28,9 +28,11 @@ namespace TLSharp.Core
|
|||
private Session _session;
|
||||
private List<TLDcOption> dcOptions;
|
||||
private TcpClientConnectionHandler _handler;
|
||||
private bool _useIpV6DataCenters;
|
||||
|
||||
public TelegramClient(int apiId, string apiHash,
|
||||
ISessionStore store = null, string sessionUserId = "session", TcpClientConnectionHandler handler = null)
|
||||
ISessionStore store = null, string sessionUserId = "session", TcpClientConnectionHandler handler = null,
|
||||
bool useIpV6DataCenters = true)
|
||||
{
|
||||
if (apiId == default(int))
|
||||
throw new MissingApiConfigurationException("API_ID");
|
||||
|
|
@ -43,6 +45,7 @@ namespace TLSharp.Core
|
|||
_apiHash = apiHash;
|
||||
_apiId = apiId;
|
||||
_handler = handler;
|
||||
_useIpV6DataCenters = useIpV6DataCenters;
|
||||
|
||||
_session = Session.TryLoadOrCreateNew(store, sessionUserId);
|
||||
_transport = new TcpTransport(_session.DataCenter.Address, _session.DataCenter.Port, _handler);
|
||||
|
|
@ -89,7 +92,7 @@ namespace TLSharp.Core
|
|||
exported = await SendRequestAsync<TLExportedAuthorization>(exportAuthorization);
|
||||
}
|
||||
|
||||
var dc = dcOptions.First(d => d.Id == dcId);
|
||||
var dc = dcOptions.First(d => d.Id == dcId && (_useIpV6DataCenters || !d.Ipv6));
|
||||
var dataCenter = new DataCenter (dcId, dc.IpAddress, dc.Port);
|
||||
|
||||
_transport = new TcpTransport(dc.IpAddress, dc.Port, _handler);
|
||||
|
|
|
|||
Loading…
Reference in a new issue