Example #1
0
        public NetworkClient(RhmsCollectingServer server, NetworkConnectionManager connectionManager)
        {
            _connectionManager = connectionManager;
            _collectingServer  = server;
            _peerControlHost   = _collectingServer.GetSettings().PeerSignalServer.Host;
            _apiAccessKey      = _collectingServer.GetSettings().ApiAccessKey;

            var sourceBindAddress = _collectingServer.GetSettings().BindAddress;

            if (!IPAddress.TryParse(sourceBindAddress, out var bindIpAddress))
            {
                bindIpAddress = IPAddress.Parse(RhmsSettings.Default.BindAddress);
                Logger.Warn($"Invalid IP address specified in settings '{sourceBindAddress}', using default '{bindIpAddress}'");
            }

            _bindEp             = new IPEndPoint(bindIpAddress, 0);
            _socket             = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            _socket.SendTimeout = _socket.ReceiveTimeout = _collectingServer.GetSettings().PeerSignalServer.SocketTimeoutMs;
            _socket.Bind(_bindEp);

            if (_peerControlHost.EndsWith("/"))
            {
                _peerControlHost = _peerControlHost.Substring(0, _peerControlHost.Length - 1);
            }

            _natUpnpCreateLocker = new object();
            NetworkRemoteControl.ClientInstance = this;
            PacketHandler = new NetPacketHandler(server, connectionManager, this);
        }
Example #2
0
        public void Write(InfluxWriteData data)
        {
            if (!data.IsValidQuery())
            {
                return;
            }

            data.AddTags(new InfluxDataPair("host", _server.GetSettings().CollectingServerPeerName));

            InternalSendData(data.QueryRequest);
        }
Example #3
0
 public string GetSelfHostId()
 {
     return(_collectingServer.GetSettings().CollectingServerPeerName);
 }