Пример #1
0
 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);
         }
     });
 }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
                }
            });
        }