public OpenPort(string name, int port, IpVersion ipVersion = IpVersion.Any, Scope scope = Scope.All, ProtocolPort protocolPort = ProtocolPort.Tcp) : this() { Name = name; Port = port; IpVersion = ipVersion; Scope = scope; ProtocolPort = protocolPort; }
public Rule(string name, Action action, ProfileType profileType = ProfileType.Domain, ProtocolPort protocolPort = ProtocolPort.Any, string interfaceTypes = "All", string localAddress = "*", string remoteAddress = "*") : this() { Name = name; Action = action; Profiles = profileType; Protocol = protocolPort; InterfaceTypes = interfaceTypes; LocalAddresses = localAddress; RemoteAddresses = remoteAddress; }
public static NET_FW_IP_PROTOCOL_ Convert(ProtocolPort item) { switch (item) { case ProtocolPort.Tcp: return(NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_TCP); case ProtocolPort.Udp: return(NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_UDP); default: return(NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_ANY); } }
private TurnMessage ProcessAllocateRequest(ref Allocation allocation, TurnMessage request, ServerEndPoint local, IPEndPoint remote) { uint sequenceNumber = (request.MsSequenceNumber != null) ? request.MsSequenceNumber.SequenceNumber : 0; { uint lifetime = (request.Lifetime != null) ? ((request.Lifetime.Value > MaxLifetime.Seconds) ? MaxLifetime.Seconds : request.Lifetime.Value) : DefaultLifetime.Seconds; if (allocation != null) { allocation.Lifetime = lifetime; if (lifetime == 0) { logger.WriteInformation(string.Format("Update Allocation: {2} seconds {0} <--> {1}", allocation.Alocated.ToString(), allocation.Reflexive.ToString(), lifetime)); } } else { if (lifetime <= 0) { throw new TurnServerException(ErrorCode.NoBinding); } ProtocolPort pp = new ProtocolPort() { Protocol = local.Protocol, }; if (peerServer.Bind(ref pp) != SocketError.Success) { throw new TurnServerException(ErrorCode.ServerError); } allocation = new Allocation() { TransactionId = request.TransactionId, ConnectionId = ConnectionIdGenerator.Generate(local, remote), Local = local, Alocated = new ServerEndPoint(pp, PublicIp), Real = new ServerEndPoint(pp, RealIp), Reflexive = new IPEndPoint(remote.Address, remote.Port), Lifetime = lifetime, }; allocations.Replace(allocation); logger.WriteInformation(string.Format("Allocated: {0} <--> {1} for {2} seconds", allocation.Alocated.ToString(), allocation.Reflexive.ToString(), allocation.Lifetime)); } } return(new TurnMessage() { IsAttributePaddingDisabled = true, MessageType = MessageType.AllocateResponse, TransactionId = request.TransactionId, MagicCookie = new MagicCookie(), MappedAddress = new MappedAddress() { IpAddress = allocation.Alocated.Address, Port = (UInt16)allocation.Alocated.Port, }, Lifetime = new Lifetime() { Value = allocation.Lifetime, }, Bandwidth = new Bandwidth() { Value = 750, }, XorMappedAddress = new XorMappedAddress(TurnMessageRfc.MsTurn) { IpAddress = remote.Address, Port = (UInt16)remote.Port, }, Realm = new Realm(TurnMessageRfc.MsTurn) { Ignore = true, Value = Authentificater.Realm, }, MsUsername = new MsUsername() { Ignore = true, Value = request.MsUsername.Value, }, //MsUsername = allocation.Username, MessageIntegrity = new MessageIntegrity(), MsSequenceNumber = new MsSequenceNumber() { ConnectionId = allocation.ConnectionId, SequenceNumber = sequenceNumber,//allocation.SequenceNumber, }, }); }