public void Serialize(XmlWriter writer) { writer.WriteStartElement("xsp-options"); if (BindAddress != null) { writer.WriteElementString("bindaddress", BindAddress.ToString()); } if (Port != null) { writer.WriteElementString("port", ((int)Port).ToString()); } if (BindRange != null) { writer.WriteStartElement("bindrange"); writer.WriteElementString("from", BindRange[0].ToString()); writer.WriteElementString("to", BindRange[1].ToString()); writer.WriteEndElement(); } if (CustomErrorsOff != null) { writer.WriteElementString("customerrorsoff", ((bool)CustomErrorsOff).ToString()); } if (LocalDirectory != null) { writer.WriteElementString("localdir", LocalDirectory); } writer.WriteEndElement(); }
/// <summary> /// UDP HolePunchingでUDP接続する /// </summary> /// <param name="PortNumber"></param> /// <returns></returns> internal (Socket s, IPEndPoint p) UdpConnect(int PortNumber) { var WaitingServerAddress = IPAddress.Any; IPEndPoint groupEP = new IPEndPoint(WaitingServerAddress, PortNumber); //クライアントが設定してくるIPあどれっす string TargetAddress; //クライアントからのメッセージ(UDPホールパンチング)を待つ //groupEPにNATが変換したアドレス+ポート番号は入ってくる using (var udpClient = new UdpClient(PortNumber)) { //Udp Hole Puchingをするために何かしらのデータを受信する(ここではクライアントが指定したサーバのアドレス) TargetAddress = Encoding.UTF8.GetString(udpClient.Receive(ref groupEP)); } //NATで変換されたIPアドレスおよびポート番号 var ip = groupEP.Address.ToString(); var port = groupEP.Port; var PunchingSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); //ソースアドレスを設定する(NATが変換できるように、クライアントが指定した宛先を設定) IPAddress BindAddress; try { BindAddress = IPAddress.Parse(TargetAddress); Logger.LogInformation($"BindAddress : {BindAddress.ToString()}"); PunchingSocket.Bind(new IPEndPoint(BindAddress, PortNumber)); } catch { try { BindAddress = NetworkInterface.IPAddresses[0]; Logger.LogInformation($"BindAddress : {BindAddress.ToString()}"); PunchingSocket.Bind(new IPEndPoint(BindAddress, PortNumber)); } catch (Exception ex) { throw ex; } } var PunchingPoint = new IPEndPoint(IPAddress.Parse(ip), port); return(PunchingSocket, PunchingPoint); }
private Boolean TryBind() { ServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); try { ServerSocket.Bind(LocalEP); Logger.Info("Server bound to " + BindAddress.ToString() + ":" + BindPort); return(true); } catch (Exception e) { Logger.Fatal(e); } return(false); }
public void SaveToRegistry() { using (var key = Registry.CurrentUser.CreateSubKey(RegKeyBase)) { key.SetValue("SuppressedSymbols", SuppressedSymbols.ToArray()); key.SetValue("EnableSuppression", EnableSuppression.ToString()); key.SetValue("BindAddress", BindAddress.ToString()); key.SetValue("BindPort", BindPort.ToString()); key.SetValue("TraceDirectory", TraceDirectory.ToString()); var vals = new List <string>(); foreach (var rm in ModulePathRemappings) { vals.Add(String.Format("{0}|{1}|{2}", rm.Platform, rm.Path, rm.ReplacementPath)); } key.SetValue("ModulePathRemappings", vals.ToArray()); key.SetValue("SymbolPaths", SymbolPaths.ToArray()); } }
public void Start() { Stop(); http_server = new HttpFileServer(HTTPPort, ServerDirectory); http_server.Start(); tftp_server = new TFTPServer(BindAddress, TFTPPort, ServerDirectory); var net = new IPSegment(BindAddress.ToString(), NetMask.ToString()); dhcp_server = new DHCPServer(BindAddress, DHCPPort); dhcp_server.Loader = loader; dhcp_server.HTTPBootFile = HTTPBootFile; dhcp_server.SubnetMask = IPAddress.Parse("255.255.255.0"); dhcp_server.PoolStart = net.Hosts().First().ToIpAddress(); dhcp_server.PoolEnd = net.Hosts().Last().ToIpAddress(); dhcp_server.Start(); }
public void Run() { if (!TryBind()) { Logger.Fatal("Unable to bind to " + BindAddress.ToString() + ":" + BindPort); } ServerSocket.Listen(0); Running = true; WorldManager.Init(); if (WorldManager.Worlds.Count == 0) { WorldManager.AddWorld(new World.World(WorldManager, "awesome_world", true)); } TickTimer = new Timer(new TimerCallback(Tick), null, 0, 50); Socket clientSocket; Client client; Thread clientThread; while (Running) { clientSocket = ServerSocket.Accept(); client = new Client(this, clientSocket); Clients.Add(clientSocket, client); clientThread = new Thread(client.Run); ClientThreads.Add(client, clientThread); clientThread.Start(); Logger.Info("New Connection: " + clientSocket.RemoteEndPoint); TotalEntityCount++; } Shutdown(); }