예제 #1
0
from Tribler.Core.Utilities.subnetparse import IP_List
from Tribler.Core.Utilities.clock import clock
from Tribler.Core.__init__ import createPeerID

from Tribler.Core.NATFirewall.upnp import UPnPPlatformIndependent,UPnPError
from Tribler.Core.NATFirewall.guessip import get_my_wan_ip
try:
    True
except:
    True = 1
    False = 0

DEBUG = False

EXPIRE_CACHE = 30 # seconds
ID = "BT-"+createPeerID()[-4:]

try:
    import pythoncom, win32com.client
    win32_imported = 1
except ImportError:
    if DEBUG and (sys.platform == 'win32'):
        print >>sys.stderr,"natpunch: ERROR: pywin32 package not installed, UPnP mode 2 won't work now" 
    win32_imported = 0

UPnPError = UPnPError

class _UPnP1:   # derived from Myers Carpenter's code
                # seems to use the machine's local UPnP
                # system for its operation.  Runs fairly fast
예제 #2
0
from Tribler.Core.Utilities.subnetparse import IP_List
from Tribler.Core.Utilities.clock import clock
from Tribler.Core.__init__ import createPeerID

from Tribler.Core.NATFirewall.upnp import UPnPPlatformIndependent, UPnPError
from Tribler.Core.NATFirewall.guessip import get_my_wan_ip
try:
    True
except:
    True = 1
    False = 0

DEBUG = False

EXPIRE_CACHE = 30  # seconds
ID = "BT-" + createPeerID()[-4:]

try:
    import pythoncom, win32com.client
    win32_imported = 1
except ImportError:
    if DEBUG and (sys.platform == 'win32'):
        print >> sys.stderr, "natpunch: ERROR: pywin32 package not installed, UPnP mode 2 won't work now"
    win32_imported = 0

UPnPError = UPnPError


class _UPnP1:  # derived from Myers Carpenter's code
    # seems to use the machine's local UPnP
    # system for its operation.  Runs fairly fast
예제 #3
0
def create_my_peer_id(my_listen_port):
    myid = createPeerID()
    myid = myid[:14] + pack('<H', my_listen_port) + myid[16:]
    return myid
예제 #4
0
def create_my_peer_id(my_listen_port):
    myid = createPeerID()
    myid = myid[:14] + pack('<H', my_listen_port) + myid[16:]
    return myid