Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## rabbit.proxy
Class Proxy

    java.lang.Object
      rabbit.proxy.Proxy

All Implemented Interfaces:
  java.lang.Runnable, Resolver, Logger

    public class Proxy

extends java.lang.Object
implements java.lang.Runnable, Logger, Resolver

This is the central dispatcher for RabbIT. Basically it sits in a loop accepting connection and for each connection creating a handler for it. Also handles logging so it goes out nicely formatted (and synchronized).

Field Summary
`protected static java.lang.String` | `CONFIG` The standard configuration file
`protected DNSHandler` | `dnsHandler` The dns handler
`protected boolean` | `proxySSL` Are we allowed to proxy ssl?
`protected java.util.List<java.lang.Integer>` | `sslports` The List of acceptable ssl-ports.
`static java.lang.String` | `VERSION` Current version

Fields inherited from interface rabbit.util.Logger
`ALL, DEBUG, ERROR, FATAL, INFO, MSG, WARN`

Constructor Summary
`Proxy()` Constructor,

Method Summary
`protected void` | `closeSocket()` Closes the serversocket and makes the proxy stop listening for connections.
`java.util.List<IPAccessFilter>` | `getAccessFilters()`
`NCache` | `getCache()` Get the cache the proxy are using.
`java.util.Map<java.lang.String,HandlerFactory>` | `getCacheHandlers()`
`Config` | `getConfig()`
`ConnectionHandler` | `getConnectionHandler()` Get the connection handler.
`int` | `getConnectPort(int port)` Get the port to connect to.
`Counter` | `getCounter()` Get the Log-handle
`java.util.List` | `getCurrentConections()` returns the current connections.
`int` | `getErrorLevel(java.lang.String errorlevel)` Get the actual error level from the given String.
`java.lang.String` | `getErrorLevelString(int errorlevel)` Get the String description of the given error level
`java.util.Map<java.lang.String,HandlerFactory>` | `getHandlers()`
`java.net.InetAddress` | `getHost()` Get the local host.
`java.util.List<HTTPFilter>` | `getHTTPInFilters()`
`java.util.List<HTTPFilter>` | `getHTTPOutFilters()`
`java.net.InetAddress` | `getInetAddress(java.net.URL url)` Get the InetAddress to connect to.
`NLSOHandler` | `getNLSOHandler()`
`long` | `getOffset()` Get the offset in milis from GMT NOTE! the offset is only calculated at startup.
`int` | `getPort()` Get the port this proxy is using.
`java.lang.String` | `getProxyAuthString()` Get the authenticationstring to use for proxy.
`java.lang.String` | `getServerIdentity()`
`java.util.Date` | `getStartDate()` return the time when the proxy was started.
`ThreadPool.Usage` | `getThreadPoolUsage()`
`java.util.TimeZone` | `getTimeZone()` Get the time zone the proxy is running in.
`WebConnection` | `getWebConnection(HTTPHeader header)` Get a WebConnection.
`boolean` | `isProxyConnected()` are we connected to another proxy?
`boolean` | `isSelf(java.lang.String uhost, int urlport)` Try hard to check if the given address matches the proxy.
`void` | `kill()` shutdown
`protected void` | `loadClasses()` Make sure all filters and handlers are available
`protected java.util.Map<java.lang.String,HandlerFactory>` | `loadHandlers(java.lang.String section)` load a set of handlers.
`void` | `logConnection(Connection con)` log a connection handled.
`void` | `logError(int type, java.lang.String error)` log errors and other important stuff.
`void` | `logError(java.lang.String error)` log errors and other important stuff.
`static void` | `main(java.lang.String[] args)` Start a proxy.
`void` | `markForPipelining(WebConnection wc)` Mark a WebConnection for pipelining.
`protected void` | `openSocket()` Open a socket on the specified port also make the proxy continue accepting connections.
`void` | `reConfigure(Config config)` Reconfigure the proxy during runtime.
`void` | `releaseWebConnection(WebConnection wc)` Release a WebConnection so that it may be reused if possible.
`void` | `removeConnection(Connection con)` Remove a connection (it has received full treatment)
`protected void` | `returnSocket(java.nio.channels.SocketChannel sc)`
`void` | `rotateLogs()` Rotate the logs.
`void` | `run()` while we can, accept new sockets, creating a handler for each and also save connections for statistics.
`void` | `saveConfig()` save the config back to file
`void` | `setProxy(java.lang.String proxyHost)` Set the proxy to use.
`void` | `setProxyPort(int newProxyPort)` Set the proxy port to use.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### VERSION

    public static final java.lang.String VERSION

  Current version

  See Also:
    Constant Field Values

### CONFIG

    protected static final java.lang.String CONFIG

  The standard configuration file

  See Also:
    Constant Field Values

### proxySSL

    protected boolean proxySSL

  Are we allowed to proxy ssl?

### sslports

    protected java.util.List<java.lang.Integer> sslports

  The List of acceptable ssl-ports.

### dnsHandler

    protected DNSHandler dnsHandler

  The dns handler

Constructor Detail

### Proxy

    public Proxy()

  Constructor,

Method Detail

### main

    public static void main(java.lang.String[] args)

  Start a proxy. Parse flags and read the config, then starts the proxy.

  Parameters:
    `args` - the command-line flags given.

### getTimeZone

    public java.util.TimeZone getTimeZone()

  Get the time zone the proxy is running in. This is neccessary to give dates in GMT.

### getOffset

    public long getOffset()

  Get the offset in milis from GMT NOTE! the offset is only calculated at startup. This means that during DST changes this may be invalid for a day or two. Restart RabbIT dayly during that time to get it right _IF_ you feel it is a problem.

### getThreadPoolUsage

    public ThreadPool.Usage getThreadPoolUsage()

### getConnectionHandler

    public ConnectionHandler getConnectionHandler()

  Get the connection handler.

### getWebConnection

    public WebConnection getWebConnection(HTTPHeader header)
                                   throws java.io.IOException

  Get a WebConnection.

  Throws:
    `java.io.IOException`

### releaseWebConnection

    public void releaseWebConnection(WebConnection wc)

  Release a WebConnection so that it may be reused if possible.

  Parameters:
    `wc` - the WebConnection to release.

### markForPipelining

    public void markForPipelining(WebConnection wc)

  Mark a WebConnection for pipelining.

  Parameters:
    `wc` - the WebConnection to mark.

### run

    public void run()

  while we can, accept new sockets, creating a handler for each and also save connections for statistics.

  Specified by:
    `run` in interface `java.lang.Runnable`

### returnSocket

    protected void returnSocket(java.nio.channels.SocketChannel sc)
                         throws java.io.IOException

  Throws:
    `java.io.IOException`

### openSocket

    protected void openSocket()

  Open a socket on the specified port also make the proxy continue accepting connections.

### closeSocket

    protected void closeSocket()

  Closes the serversocket and makes the proxy stop listening for connections.

### reConfigure

    public void reConfigure(Config config)

  Reconfigure the proxy during runtime.

  Parameters:
    `config` - the new config.

### rotateLogs

    public void rotateLogs()

  Rotate the logs.

### setProxy

    public void setProxy(java.lang.String proxyHost)
                  throws java.net.UnknownHostException

  Set the proxy to use.

  Throws:
    `java.net.UnknownHostException`

### setProxyPort

    public void setProxyPort(int newProxyPort)

  Set the proxy port to use.

### saveConfig

    public void saveConfig()

  save the config back to file

### getErrorLevel

    public int getErrorLevel(java.lang.String errorlevel)

  Get the actual error level from the given String.

  Parameters:
    `errorlevel` - the String to translate.
  Returns:
    the errorlevel suitable for the given String.

### getErrorLevelString

    public java.lang.String getErrorLevelString(int errorlevel)

  Get the String description of the given error level

  Parameters:
    `errorlevel` - the int to translate to a String.
  Returns:
    the String describing the errorlevel.

### logError

    public void logError(java.lang.String error)

  log errors and other important stuff.

  Specified by:
    `logError` in interface `Logger`
  Parameters:
    `error` - the thing that happend.

### logError

    public void logError(int type,
                         java.lang.String error)

  log errors and other important stuff.

  Specified by:
    `logError` in interface `Logger`
  Parameters:
    `type` - the type of the error.
    `error` - the thing that happend.

### getConfig

    public Config getConfig()

### getCache

    public NCache getCache()

  Get the cache the proxy are using.

  Returns:
    the NCache the proxy currently are using.

### getCounter

    public Counter getCounter()

  Get the Log-handle

  Returns:
    the Counter we use.

### getPort

    public int getPort()

  Get the port this proxy is using.

  Returns:
    the port number the proxy is listening on.

### getHost

    public java.net.InetAddress getHost()

  Get the local host.

  Returns:
    the InetAddress of the host the proxy is running on.

### isSelf

    public boolean isSelf(java.lang.String uhost,
                          int urlport)

  Try hard to check if the given address matches the proxy. Will use the localhost name and all ip addresses.

### isProxyConnected

    public boolean isProxyConnected()

  are we connected to another proxy?

  Specified by:
    `isProxyConnected` in interface `Resolver`
  Returns:
    true if the proxy is connected to another proxy.

### getInetAddress

    public java.net.InetAddress getInetAddress(java.net.URL url)
                                        throws java.net.UnknownHostException

  Get the InetAddress to connect to.

  Specified by:
    `getInetAddress` in interface `Resolver`
  Returns:
    the InetAddress to give the request
  Throws:
    `java.net.UnknownHostException`

### getConnectPort

    public int getConnectPort(int port)

  Get the port to connect to.

  Specified by:
    `getConnectPort` in interface `Resolver`
  Parameters:
    `port` - the port we want to connect to.
  Returns:
    the port to connect to.

### getProxyAuthString

    public java.lang.String getProxyAuthString()

  Get the authenticationstring to use for proxy.

  Specified by:
    `getProxyAuthString` in interface `Resolver`
  Returns:
    an authentication string.

### getCurrentConections

    public java.util.List getCurrentConections()

  returns the current connections.

  Returns:
    a List with the current connections.

### removeConnection

    public void removeConnection(Connection con)

  Remove a connection (it has received full treatment)

  Parameters:
    `con` - the connection that is closing down.

### getStartDate

    public java.util.Date getStartDate()

  return the time when the proxy was started.

  Returns:
    a Date with the time the proxy was started.

### getServerIdentity

    public java.lang.String getServerIdentity()

### getHandlers

    public java.util.Map<java.lang.String,HandlerFactory> getHandlers()

### getCacheHandlers

    public java.util.Map<java.lang.String,HandlerFactory> getCacheHandlers()

### getAccessFilters

    public java.util.List<IPAccessFilter> getAccessFilters()

### getHTTPInFilters

    public java.util.List<HTTPFilter> getHTTPInFilters()

### getHTTPOutFilters

    public java.util.List<HTTPFilter> getHTTPOutFilters()

### getNLSOHandler

    public NLSOHandler getNLSOHandler()

### loadHandlers

    protected java.util.Map<java.lang.String,HandlerFactory> loadHandlers(java.lang.String section)

  load a set of handlers.

  Parameters:
    `section` - the section in the config file.
  Returns:
    a Map with mimetypes as keys and Handlers as values.

### loadClasses

    protected void loadClasses()

  Make sure all filters and handlers are available

### logConnection

    public void logConnection(Connection con)

  log a connection handled.

  Parameters:
    `con` - the Connection that handled a request

### kill

    public void kill()

  shutdown

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD