From 0a49ccdd94c2cef667088460fe8efb1f922354dc Mon Sep 17 00:00:00 2001 From: Kyuho Jeong Date: Wed, 30 Sep 2015 22:25:57 -0400 Subject: [PATCH] keyring and stat report --- gvpn/CFx.py | 23 ++++++++++++++++++----- gvpn/config.json | 7 ++++++- gvpn/ipoplib.py | 11 +++++++++-- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/gvpn/CFx.py b/gvpn/CFx.py index cf0145e..48a29b6 100644 --- a/gvpn/CFx.py +++ b/gvpn/CFx.py @@ -3,6 +3,7 @@ import os import sys import json +import keyring import time import signal import socket @@ -16,6 +17,7 @@ from CBT import CBT as _CBT from CFxHandle import CFxHandle +CONFIG = ipoplib.CONFIG class CFX(object): @@ -44,8 +46,10 @@ def __init__(self): self.ip4 = self.CONFIG['AddressMapper']["ip4"] if(self.vpn_type == 'GroupVPN'): self.uid = ipoplib.gen_uid(self.ip4) # SHA-1 Hash + CONFIG["uid"] = self.uid elif(self.vpn_type == 'SocialVPN'): self.uid = self.CONFIG['CFx']['local_uid'] + CONFIG["uid"] = self.uid self.ip6 = ipoplib.gen_ip6(self.uid) if socket.has_ipv6: @@ -300,12 +304,21 @@ def parse_config(self): "must be specified in config file or string") if "xmpp_password" not in self.CONFIG["CFx"]: - prompt = "\nPassword for %s:" % self.CONFIG["CFx"]["xmpp_username"] - if args.pwdstdout: - self.CONFIG["CFx"]["xmpp_password"] = getpass(prompt, + if not args.update_config: + temp = keyring.get_password("ipop", CONFIG["xmpp_username"]) + if temp == None and "xmpp_password" not in CONFIG: + prompt = "\nPassword for %s:" % self.CONFIG["CFx"]["xmpp_username"] + if args.pwdstdout: + self.CONFIG["CFx"]["xmpp_password"] = getpass(prompt, stream=sys.stdout) - else: - self.CONFIG["CFx"]["xmpp_password"] = getpass(prompt) + else: + self.CONFIG["CFx"]["xmpp_password"] = getpass(prompt) + if temp != None: + CONFIG["xmpp_password"] = temp + try: + keyring.set_password("ipop", CONFIG["xmpp_username"],CONFIG["xmpp_password"]) + except: + raise RuntimeError("Unable to store password in keyring") if args.ip_config: ipoplib.load_peer_ip_config(args.ip_config) diff --git a/gvpn/config.json b/gvpn/config.json index 67834d6..68a9356 100644 --- a/gvpn/config.json +++ b/gvpn/config.json @@ -6,7 +6,7 @@ "xmpp_host": "", "stat_report": true, "tincan_logging": 0, - "icc": true, + "icc": false, "icc_port": 30000, "vpn_type": "GroupVPN" }, @@ -49,6 +49,11 @@ "timer_interval": 15, "joinEnabled": true, "dependencies": ["Logger"] + }, + "StatReport":{ + "timer_interval": 1, + "joinEnabled": true, + "dependencies": ["Logger"] } } diff --git a/gvpn/ipoplib.py b/gvpn/ipoplib.py index c6b6807..2940f5f 100644 --- a/gvpn/ipoplib.py +++ b/gvpn/ipoplib.py @@ -41,7 +41,7 @@ "multihop_sr": True, # Multihop source route "stat_report": False, "stat_server": "metrics.ipop-project.org", - "stat_server_port": 5000 + "stat_server_port": 80 }, "TincanListener": { "buf_size": 65507, @@ -90,7 +90,14 @@ "Watchdog": { "timer_interval": 15, "joinEnabled": False, - } + }, + "StatReport": { + "timer_interval": 200, + "joinEnabled": True, + }, + "uid" : None, + "ipop_ver" : "\x02" + } IP_MAP = {}