Changeset 1253


Ignore:
Timestamp:
Oct 22, 2010, 10:47:40 AM (11 years ago)
Author:
Nicklas Nordborg
Message:

Added configuration option for specifying which local address to listen on.

Location:
extensions/net.sf.basedb.torrent/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.torrent/trunk/src/main/net/sf/basedb/clients/torrent/service/TorrentService.java

    r1251 r1253  
    2828
    2929import java.io.IOException;
     30import java.net.InetAddress;
     31import java.net.InetSocketAddress;
    3032import java.util.Properties;
    3133
     
    8587
    8688  private final java.io.File workDir;
     89  private final String address;
    8790  private final int port;
    8891  private volatile boolean isRunning;
    8992  private Client btClient;
     93  private InetSocketAddress listenAddress;
    9094 
    9195  /**
     
    100104    }
    101105    this.workDir = new java.io.File(dir);
     106    this.address = Values.getStringOrNull(properties.getProperty("torrents.listen-address"));
    102107    this.port = Values.getInt(properties.getProperty("torrents.listen-port"));
    103108  }
     
    119124    log.info("Starting Bittorrent Download Service");
    120125    log.debug("Working directory: " + workDir);
     126    log.debug("Listen address: " + address);
    121127    log.debug("Listen port: " + port);
    122128   
     
    137143      {
    138144        tmpClient = new Client();
    139         tmpClient.startProtocol(port);
     145        InetAddress tmpAddress = null;
     146        if (address != null) tmpAddress = InetAddress.getByName(address);
     147        InetSocketAddress socketAddress = new InetSocketAddress(tmpAddress, port);
     148        listenAddress = tmpClient.startProtocol(socketAddress);
     149        log.debug("Connected to: " + listenAddress);
    140150      }
    141151      catch (IOException ex)
  • extensions/net.sf.basedb.torrent/trunk/torrent.properties

    r1246 r1253  
    77torrents.work-dir =
    88
     9# The local address the torrent service will listen on for incoming connections.
     10# If not specified it will listen to the wildcard address (0.0.0.0)
     11torrents.listen-address =
     12
    913# The port the torrent service will listen on for incoming connections.
    10 torrents.listen-port  = 17777
     14# If 0 or not specified the system will select a random free port
     15torrents.listen-port  =
    1116
Note: See TracChangeset for help on using the changeset viewer.