public async Task DeletePortMapping( int externalPort, ProtocolType protocol = ProtocolType.Tcp, string remoteHost = "") { await ExecuteService(DeviceType.InternetGatewayDevice, ServiceType.WanIpConnection, async ( a, b ) => { using (var serviceClient = new Core.Services.WanIpConnectionClient(a.Location.ToString(), b.ControlUrl, b.TypeName)) { await serviceClient.DeletePortMapping(externalPort, protocol, remoteHost); } }); }
public async Task <List <Core.Services.WanIpConnectionClient.PortMapping> > GetGenericPortMappingEntry(int index) { List <Core.Services.WanIpConnectionClient.PortMapping> result = new List <Core.Services.WanIpConnectionClient.PortMapping>(); await ExecuteService(DeviceType.InternetGatewayDevice, ServiceType.WanIpConnection, async ( a, b ) => { using (var serviceClient = new Core.Services.WanIpConnectionClient(a.Location.ToString(), b.ControlUrl, b.TypeName)) { result.Add(await serviceClient.GetGenericPortMappingEntry(index)); } }); return(result); }
public async Task <List <string> > GetExternalAddressList() { List <string> result = new List <string>(); await ExecuteService(DeviceType.InternetGatewayDevice, ServiceType.WanIpConnection, async ( a, b ) => { using (var serviceClient = new Core.Services.WanIpConnectionClient(a.Location.ToString(), b.ControlUrl, b.TypeName)) { result.Add(await serviceClient.GetExternalIpAddress()); } }); return(result); }
public async Task AddPortMapping( int internalPort, int externalPort, string internalHost = null, ProtocolType protocol = ProtocolType.Tcp, string description = null, TimeSpan leaseDuration = new TimeSpan(), bool isEnabled = true, string remoteHost = "") { await ExecuteService(DeviceType.InternetGatewayDevice, ServiceType.WanIpConnection, async ( a, b ) => { if (string.IsNullOrEmpty(internalHost)) { internalHost = a.LocalAddress.ToString(); } using (var serviceClient = new Core.Services.WanIpConnectionClient(a.Location.ToString(), b.ControlUrl, b.TypeName)) { await serviceClient.AddPortMapping(internalHost, internalPort, externalPort, protocol, description, leaseDuration, isEnabled, remoteHost); } }); }