Exemplo n.º 1
0
 /// <summary>
 /// Deletes a mapped port asynchronous.
 /// </summary>
 /// <param name="mapping">The <see cref="Mapping">Mapping</see> entry.</param>
 /// <example>
 /// device.DeletePortMapAsync(new Mapping(Protocol.Tcp, 1700, 1600));
 /// </example>
 /// <exception cref="MappingException">MappingException-class</exception>
 public abstract Task DeletePortMapAsync(Mapping mapping);
Exemplo n.º 2
0
 /// <summary>
 /// Creates the port map asynchronous.
 /// </summary>
 /// <param name="mapping">The <see cref="Mapping">Mapping</see> entry.</param>
 /// <example>
 /// device.CreatePortMapAsync(new Mapping(Protocol.Tcp, 1700, 1600));
 /// </example>
 /// <exception cref="MappingException">MappingException</exception>
 public abstract Task CreatePortMapAsync(Mapping mapping);
Exemplo n.º 3
0
        private async Task RenewMapping(Mapping mapping)
        {
            var renewMapping = new Mapping(mapping);
            try
            {
                renewMapping.Expiration = DateTime.UtcNow.AddSeconds(mapping.Lifetime);

                NatDiscoverer.TraceSource.LogInfo("Renewing mapping {0}", renewMapping);
                await CreatePortMapAsync(renewMapping);
                NatDiscoverer.TraceSource.LogInfo("Next renew scheduled at: {0}",
                                                  renewMapping.Expiration.ToLocalTime().TimeOfDay);
            }
            catch (Exception)
            {
                NatDiscoverer.TraceSource.LogWarn("Renew {0} failed", mapping);
            }
        }
Exemplo n.º 4
0
 protected void UnregisterMapping(Mapping mapping)
 {
     _openedMapping.RemoveWhere(x => x.Equals(mapping));
 }
Exemplo n.º 5
0
 protected void RegisterMapping(Mapping mapping)
 {
     _openedMapping.Remove(mapping);
     _openedMapping.Add(mapping);
 }
Exemplo n.º 6
0
 internal Mapping(Mapping mapping)
 {
     PrivateIP = mapping.PrivateIP;
     PrivatePort = mapping.PrivatePort;
     Protocol = mapping.Protocol;
     PublicIP = mapping.PublicIP;
     PublicPort = mapping.PublicPort;
     LifetimeType = mapping.LifetimeType;
     Description = mapping.Description;
     _lifetime = mapping._lifetime;
     _expiration = mapping._expiration;
 }