示例#1
0
        /**
         * Handles packets coming in on the Proxy port. Decides whether
         * packets coming in on Auth/Acct ports should be proxied.
         */

        protected override RadiusPacket HandlePacket(IPEndPoint localAddress, IPEndPoint remoteAddress,
                                                     RadiusPacket request, String sharedSecret)
        {
            // handle incoming Proxy packet
            if (localAddress.Port == ProxyPort)
            {
                proxyPacketReceived(request, remoteAddress);
                return(null);
            }

            // handle auth/acct packet
            var            radiusClient = new RadiusEndpoint(remoteAddress, sharedSecret);
            RadiusEndpoint radiusServer = GetProxyServer(request, radiusClient);

            if (radiusServer != null)
            {
                // Proxy incoming packet to other radius server
                var proxyConnection = new RadiusProxyConnection(radiusServer, radiusClient, request,
                                                                localAddress.Port);
                logger.Info("Proxy packet to " + proxyConnection);
                proxyPacket(request, proxyConnection);
                return(null);
            }
            else
            {
                // normal processing
                return(base.HandlePacket(localAddress, remoteAddress, request, sharedSecret));
            }
        }
示例#2
0
        /**
         * Proxies the given packet to the server given in the Proxy connection.
         * Stores the Proxy connection object in the cache with a key that
         * is added to the packet in the "Proxy-State" attribute.
         * @param packet the packet to Proxy
         * @param proxyCon the RadiusProxyConnection for this packet
         * @throws IOException
         */

        protected void proxyPacket(RadiusPacket packet, RadiusProxyConnection proxyConnection)
        {
            lock (typeof(RadiusProxy))
            {
                // add Proxy-State attribute
                proxyIndex++;
                String proxyIndexStr = proxyIndex.ToString();
                packet.AddAttribute(new RadiusAttribute(33, Encoding.UTF8.GetBytes(proxyIndexStr)));

                // store RadiusProxyConnection object
                proxyConnections.Add(proxyIndexStr, proxyConnection);
            }

            // get server address
            //IPAddress serverAddress = proxyConnection.getRadiusServer().EndpointAddress.Address;
            //int serverPort = proxyConnection.getRadiusServer().EndpointAddress.Port;
            String serverSecret = proxyConnection.RadiusServer.SharedSecret;

            // save request authenticator (will be calculated new)
            byte[] auth = packet.Authenticator;

            // encode new packet (with new authenticator)
            var bos = new MemoryStream();

            packet.EncodeRequestPacket(bos, serverSecret);
            byte[] data = bos.ToArray();
            bos.Dispose();


            //var datagram = new DatagramPacket(data, data.Length, serverAddress, serverPort);

            // restore original authenticator
            packet.Authenticator = auth;

            // send packet
            //Socket proxySocket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.IP);
            proxySocket.Send(data, data.Length);
            //proxySocket.send(datagram);
        }
示例#3
0
        /**
         * Proxies the given packet to the server given in the Proxy connection.
         * Stores the Proxy connection object in the cache with a key that
         * is added to the packet in the "Proxy-State" attribute.
         * @param packet the packet to Proxy
         * @param proxyCon the RadiusProxyConnection for this packet
         * @throws IOException
         */

        protected void proxyPacket(RadiusPacket packet, RadiusProxyConnection proxyConnection)
        {
            lock (typeof (RadiusProxy))
            {
                // add Proxy-State attribute
                proxyIndex++;
                String proxyIndexStr = proxyIndex.ToString();
                packet.AddAttribute(new RadiusAttribute(33, Encoding.UTF8.GetBytes(proxyIndexStr)));

                // store RadiusProxyConnection object
                proxyConnections.Add(proxyIndexStr, proxyConnection);
            }

            // get server address
            //IPAddress serverAddress = proxyConnection.getRadiusServer().EndpointAddress.Address;
            //int serverPort = proxyConnection.getRadiusServer().EndpointAddress.Port;
            String serverSecret = proxyConnection.RadiusServer.SharedSecret;

            // save request authenticator (will be calculated new)
            byte[] auth = packet.Authenticator;

            // encode new packet (with new authenticator)
            var bos = new MemoryStream();
            packet.EncodeRequestPacket(bos, serverSecret);
            byte[] data = bos.ToArray();
            bos.Dispose();


            //var datagram = new DatagramPacket(data, data.Length, serverAddress, serverPort);

            // restore original authenticator
            packet.Authenticator = auth;

            // send packet
            //Socket proxySocket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.IP);
            proxySocket.Send(data, data.Length);
            //proxySocket.send(datagram);
        }
示例#4
0
        /**
         * Handles packets coming in on the Proxy port. Decides whether
         * packets coming in on Auth/Acct ports should be proxied.
         */

        protected override RadiusPacket HandlePacket(IPEndPoint localAddress, IPEndPoint remoteAddress,
                                                     RadiusPacket request, String sharedSecret)
        {
            // handle incoming Proxy packet
            if (localAddress.Port == ProxyPort)
            {
                proxyPacketReceived(request, remoteAddress);
                return null;
            }

            // handle auth/acct packet
            var radiusClient = new RadiusEndpoint(remoteAddress, sharedSecret);
            RadiusEndpoint radiusServer = GetProxyServer(request, radiusClient);
            if (radiusServer != null)
            {
                // Proxy incoming packet to other radius server
                var proxyConnection = new RadiusProxyConnection(radiusServer, radiusClient, request,
                                                                localAddress.Port);
                logger.Info("Proxy packet to " + proxyConnection);
                proxyPacket(request, proxyConnection);
                return null;
            }
            else
                // normal processing
                return base.HandlePacket(localAddress, remoteAddress, request, sharedSecret);
        }