Exemple #1
0
def get_map():
    try:
        cjdns = cjdns_connect(cjdadmin_ip, cjdadmin_port, cjdadmin_pass)
    except:
        cjdns = cjdns_connectWithAdminInfo()
    
    routes = get_routes(cjdns)
    routes = sort_routes_on_quality(routes)
    nodes = get_nodes(routes)
    edges = get_edges(routes, nodes)

    node_names = download_node_names()
    update_names(node_names, nodes)

    return nodes.values(), edges
Exemple #2
0
 
    m = v - chroma
    r += m
    g += m
    b += m
    return (r,g,b)
    
def hsv_to_color(h,s,v):
    r,g,b = hsv_to_rgb(h,s,v)
    return '#{0:02x}{1:02x}{2:02x}'.format(int(r*255),int(g*255),int(b*255))


###################################################

try:
    cjdns = cjdns_connect(cjdadmin_ip, cjdadmin_port, cjdadmin_pass)
except:
    cjdns = cjdns_connectWithAdminInfo()

# WARNING: this depends on implementation quirks of the router and will be broken in the future.
def is_one_hop(parent, child):
    c = child >> int(math.log(parent,2));
    if c & 1: return int(math.log(c,2)) == 4;
    if c & 3: return int(math.log(c,2)) == 7;
    return math.log(c,2) == 10;

class route:
    def __init__(self, ip, name, path, link):
        self.ip = ip
        self.name = name
        route = path
Exemple #3
0
def addPeer(record):
    print "Adding peer..."
    sys.path.append(import_path)
    from cjdns import cjdns_connect
    cjdns = cjdns_connect("127.0.0.1", adminPort, adminPassword)
    cjdns.UDPInterface_beginConnection(record["key"],record["ip"] + ":" + record["port"],0,record["password"])
Exemple #4
0
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import sys;
from cjdns import cjdns_connect;

if (len(sys.argv) < 4):
    print("Usage " + sys.argv[0] + " <ip addr> <port> <password>");
    exit(0);

cjdns = cjdns_connect(sys.argv[1], int(sys.argv[2]), sys.argv[3]);
addresses = {};
allRoutes = [];

i = 0;
while True:
    table = cjdns.NodeStore_dumpTable(i);
    routes = table['routingTable'];
    allRoutes += routes;
    for entry in routes:
        if (entry['link'] != 0):
            addresses[entry['ip']] = entry['path'];
        #print entry['ip'] + '@' + entry['path'] + ' - ' + str(entry['link']);
    if (not 'more' in table):
        break;
    i += 1;
Exemple #5
0
    r += m
    g += m
    b += m
    return (r, g, b)


def hsv_to_color(h, s, v):
    r, g, b = hsv_to_rgb(h, s, v)
    return '#{0:02x}{1:02x}{2:02x}'.format(int(r * 255), int(g * 255),
                                           int(b * 255))


###################################################

try:
    cjdns = cjdns_connect(cjdadmin_ip, cjdadmin_port, cjdadmin_pass)
except:
    cjdns = cjdns_connectWithAdminInfo()


# WARNING: this depends on implementation quirks of the router and will be broken in the future.
def is_one_hop(parent, child):
    c = child >> int(math.log(parent, 2))
    if c & 1: return int(math.log(c, 2)) == 4
    if c & 3: return int(math.log(c, 2)) == 7
    return math.log(c, 2) == 10


class route:
    def __init__(self, ip, name, path, link):
        self.ip = ip
Exemple #6
0
def generatepass():
    letters = "1234567890abcdefghijklmnopqrstuvwxyz"
    length = 20
    out = ""
    while len(out) <= length:
        out += letters[random.randint(0, len(letters) - 1)]
    return out


password = generatepass()

print "Using password " + password

sys.path.append(import_path)
from cjdns import cjdns_connect
cjdns = cjdns_connect("127.0.0.1", adminPort, adminPassword)
addpass = cjdns.AuthorizedPasswords_add(password)
if addpass["error"] != "none":
    print "Adding password failed!"
    sys.exit()

service = ZeroconfService(name="Hyperboria Peer " + name, port=port, stype="_cjdns._udp",
    text=["password="******"key=" + public_key, "name=" + name, "cjdnsip=" + ip])

service.publish()
print "Service published!"
raw_input("Press enter to stop broadcasting")
print "Unpublishing service..."
service.unpublish()