/**
         * Creates a RadiusProxyConnection object.
         * @param radiusServer server endpoint
         * @param radiusClient client endpoint
         * @param port port the proxied packet arrived at originally 
         */

        public RadiusProxyConnection(RadiusEndpoint radiusServer, RadiusEndpoint radiusClient, RadiusPacket packet,
                                     int port)
        {
            RadiusServer = radiusServer;
            RadiusClient = radiusClient;
            Packet = packet;
            Port = port;
        }
Ejemplo n.º 2
0
 public override RadiusEndpoint GetProxyServer(RadiusPacket packet,
                                               RadiusEndpoint client)
 {
     // always proxy
     try
     {
         IPAddress address = IPAddress.Parse("127.0. 0. 1 ");
         int port = 10000;
         if (typeof (AccountingRequest).IsInstanceOfType(packet))
             port = 10001;
         return new RadiusEndpoint(new IPEndPoint(address, port), "testing123");
     }
     catch
     {
         return null;
     }
 }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
 /**
  * This method must be implemented to return a RadiusEndpoint
  * if the given packet is to be proxied. The endpoint represents the
  * Radius server the packet should be proxied to.
  * @param packet the packet in question
  * @param client the client endpoint the packet originated from
  * (containing the address, port number and shared secret)
  * @return a RadiusEndpoint or null if the packet should not be
  * proxied
  */
 public abstract RadiusEndpoint GetProxyServer(RadiusPacket packet, RadiusEndpoint client);
Ejemplo n.º 5
0
        /**
         * Sends the specified packet to the specified Radius server endpoint.
         * @param remoteServer Radius endpoint consisting of server address,
         * port number and shared secret
         * @param request Radius packet to be sent 
         * @return received response packet
         * @throws RadiusException malformed packet
         * @throws IOException error while communication
         */

        public static RadiusPacket Communicate(RadiusEndpoint remoteServer, RadiusPacket request)
        {
            var rc = new RadiusClient(remoteServer.EndpointAddress.Address, remoteServer.SharedSecret);
            return rc.Communicate(request, remoteServer.EndpointAddress.Port);
        }
Ejemplo n.º 6
0
        /**
         * Sends the specified packet to the specified Radius server endpoint.
         * @param remoteServer Radius endpoint consisting of server address,
         * port number and shared secret
         * @param request Radius packet to be sent
         * @return received response packet
         * @throws RadiusException malformed packet
         * @throws IOException error while communication
         */

        public static RadiusPacket Communicate(RadiusEndpoint remoteServer, RadiusPacket request)
        {
            var rc = new RadiusClient(remoteServer.EndpointAddress.Address, remoteServer.SharedSecret);

            return(rc.Communicate(request, remoteServer.EndpointAddress.Port));
        }