private static void OpenPort() { Netplay.portForwardIP = Netplay.GetLocalIPAddress(); Netplay.portForwardPort = Netplay.ListenPort; if (Netplay.upnpnat == null) { Netplay.upnpnat = (UPnPNAT)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("AE1E00AA-3FD5-403C-8A27-2BBDC30CD0E1"))); Netplay.mappings = Netplay.upnpnat.StaticPortMappingCollection; } if (Netplay.mappings == null) { return; } foreach (IStaticPortMapping mapping in Netplay.mappings) { if (mapping.InternalPort == Netplay.portForwardPort && mapping.InternalClient == Netplay.portForwardIP && mapping.Protocol == "TCP") { Netplay.portForwardOpen = true; } } if (Netplay.portForwardOpen) { return; } // ISSUE: reference to a compiler-generated method Netplay.mappings.Add(Netplay.portForwardPort, "TCP", Netplay.portForwardPort, Netplay.portForwardIP, true, "Terraria Server"); Netplay.portForwardOpen = true; }
private static void OpenPort(int port) { string localIpAddress = Netplay.GetLocalIPAddress(); if (Netplay._upnpnat == null) { Netplay._upnpnat = (UPnPNAT)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("AE1E00AA-3FD5-403C-8A27-2BBDC30CD0E1"))); Netplay._mappings = Netplay._upnpnat.StaticPortMappingCollection; } if (Netplay._mappings == null) { return; } bool flag = false; foreach (IStaticPortMapping mapping in Netplay._mappings) { if (mapping.InternalPort == port && mapping.InternalClient == localIpAddress && mapping.Protocol == "TCP") { flag = true; } } if (flag) { return; } // ISSUE: reference to a compiler-generated method Netplay._mappings.Add(port, "TCP", port, localIpAddress, true, "Terraria Server"); }
private static void ClosePort(int port) { string localIpAddress = Netplay.GetLocalIPAddress(); bool flag = false; if (Netplay._mappings == null) { return; } foreach (IStaticPortMapping mapping in Netplay._mappings) { if (mapping.InternalPort == port && mapping.InternalClient == localIpAddress && mapping.Protocol == "TCP") { flag = true; } } if (flag) { return; } // ISSUE: reference to a compiler-generated method Netplay._mappings.Remove(port, "TCP"); }
private static void OpenPort() { Netplay.portForwardIP = Netplay.GetLocalIPAddress(); Netplay.portForwardPort = Netplay.ListenPort; }