コード例 #1
0
ファイル: manage_base.py プロジェクト: 360sec/jkdns
def domain():
    auth_result = auth_user()
    if not auth_result[0]:
        return redirect(auth_result[1])
    else:
        userinfo = auth_result[1]
    domain_id = request.args.get('domain_id', '')
    if not Domain.test_if_domain_id_exists(int(domain_id)):
        return redirect("/manage/domain_list")
    user_domain_list = get_domain_list_by_user_id(userinfo['user_id'])
    domain_info = Domain.get_domain_by_domain_id(domain_id)
    if if_user_id_have_domain_rights(userinfo['user_id'], domain_id):
        return render_template("manage_domain_have_rights.html", userinfo=userinfo, user_domain_list=user_domain_list, domain_info=domain_info)
    else:
        return render_template("manage_domain_no_rights.html", userinfo=userinfo, user_domain_list=user_domain_list, domain_info=domain_info)
コード例 #2
0
ファイル: dnspod_lib.py プロジェクト: 360sec/jkdns
def get_dnspod_record_list_by_domain_id_lib(domain_id):
    domain_info = Domain.get_domain_by_domain_id(domain_id)
    if not domain_info:
        return []
    domain_name = domain_info[1]
    tag = 0
    dnspod_domain_list = get_dnspod_domain_list()
    for dnspod_domain in dnspod_domain_list:
        if dnspod_domain['name'] == domain_name:
            tag = 1
            dnspod_domain_id = dnspod_domain['id']
    if tag == 0:
        return []

    tmp_list = []
    dns_record_list = get_dnspod_record_list_by_domain_id(dnspod_domain_id)
    for dns_record in dns_record_list:
        tmp_dict = {}
        tmp_dict['id'] = dns_record['id']
        tmp_dict['domain_id'] = domain_id
        tmp_dict['name'] = dns_record['name']
        tmp_dict['line'] = dns_record['line']
        ttl = dns_record['ttl']
        tmp_dict['ttl'] = ttl
        tmp_dict['type'] = dns_record['type']
        tmp_dict['value'] = dns_record['value']
        tmp_dict['state'] = dns_record['enabled']
        if dns_record['type'] == "A" :
            if ipFormatChk(dns_record['value']):
                tmp_list.append(tmp_dict)
        else:
            tmp_list.append(tmp_dict)
    return tmp_list
コード例 #3
0
ファイル: dnspod_lib.py プロジェクト: 360sec/jkdns
def get_dnspod_record_list_by_domain_id_and_record_lib(domain_id, record):
    domain_info = Domain.get_domain_by_domain_id(domain_id)
    if not domain_info:
        return []
    domain_name = domain_info[1]
    tag = 0
    dnspod_domain_list = get_dnspod_domain_list()
    for dnspod_domain in dnspod_domain_list:
        if dnspod_domain['name'] == domain_name:
            tag = 1
            dnspod_domain_id = dnspod_domain['id']
    if tag == 0:
        return []
    record_list = get_dnspod_record_list_by_domain_id_lib(domain_id)
    record_id = 0
    tmp_list = []
    for tmp_record in record_list:
        if tmp_record['name'] == record:
            tmp_dict = {}
            record_id = tmp_record['id']
            dns_record = get_dnspod_record_list_by_domain_id_and_record_id(dnspod_domain_id, record_id)
            tmp_dict['id'] = dns_record['id']
            tmp_dict['domain_id'] = domain_id
            tmp_dict['name'] = dns_record['sub_domain']
            tmp_dict['line'] = dns_record['record_line']
            ttl = dns_record['ttl']
            tmp_dict['ttl'] = ttl
            tmp_dict['type'] = dns_record['record_type']
            tmp_dict['value'] = dns_record['value']
            tmp_dict['state'] = dns_record['enabled']
            tmp_list.append(tmp_dict)
    return tmp_list
コード例 #4
0
ファイル: manage_api.py プロジェクト: 360sec/jkdns
def del_record_api():
    tmp_dict = {}
    tmp_dict["success"] = "False"
    auth_result = auth_user()
    if not auth_result[0]:
        tmp_dict["msg"] = "no sso auth"
        return json.dumps(tmp_dict)
    else:
        userinfo = auth_result[1]
    if request.method == "POST":
        try:
            domain_id = request.form["domain_id"]
            domain_info = Domain.get_domain_by_domain_id(domain_id)
            record_id = request.form["record_id"]
            if if_user_id_have_domain_rights(userinfo["user_id"], domain_id):
                Logger.action_log(userinfo["username"] + " del record ")
                if domain_info[2] == "dnspod":
                    result = del_dnspod_record_lib(domain_id, record_id)
                    tmp_dict["success"] = result[0]
                    tmp_dict["msg"] = result[1]
                    return json.dumps(tmp_dict)
                elif domain_info[2] == "local_bind":
                    result = del_dns_record_lib(domain_id, record_id)
                    tmp_dict["success"] = result[0]
                    tmp_dict["msg"] = result[1]
                    return json.dumps(tmp_dict)
            else:
                tmp_dict["msg"] = "no this domain rights"
                return json.dumps(tmp_dict)
        except Exception, e:
            print e
            tmp_dict["msg"] = "unknown error"
            return json.dumps(tmp_dict)
コード例 #5
0
ファイル: domain_lib.py プロジェクト: 360sec/jkdns
def get_all_domain_dict_lib():
    tmp_list = []
    domain_list = Domain.get_all_domain()
    for domain in domain_list:
        tmp_dict = {}
        tmp_dict['domain_id'] = domain[0]
        tmp_dict['domain_name'] = domain[1]
        tmp_dict['type'] = domain[2]
        tmp_list.append(tmp_dict)
    return tmp_list
コード例 #6
0
ファイル: user_domain_lib.py プロジェクト: 360sec/jkdns
def get_domain_list_by_user_id(user_id):
    tmp_list = []
    user_domain_list = User_domain.get_user_domain_list_by_user_id(user_id)
    for user_domain in user_domain_list:
        try:
            tmp_dict = {}
            domain = Domain.get_domain_by_domain_id(user_domain[2])
            tmp_dict['domain_id'] = domain[0]
            tmp_dict['domain_name'] = domain[1]
            tmp_dict['type'] = domain[2]
            tmp_list.append(tmp_dict)
        except:
            print "error"
    return tmp_list
コード例 #7
0
ファイル: dnspod_lib.py プロジェクト: 360sec/jkdns
def stop_dnspod_record_lib(domain_id, record_id):
    domain_info = Domain.get_domain_by_domain_id(domain_id)
    if not domain_info:
        return ["false","no this domain"]
    domain_name = domain_info[1]
    tag = 0
    dnspod_domain_list = get_dnspod_domain_list()
    for dnspod_domain in dnspod_domain_list:
        if dnspod_domain['name'] == domain_name:
            tag = 1
            dnspod_domain_id = dnspod_domain['id']
            break
    if tag == 0:
        return ["false", "no this domain in dnspod"]
    result = change_dnspod_record_status(dnspod_domain_id, record_id, "disable")
    return result
コード例 #8
0
ファイル: dnspod_lib.py プロジェクト: 360sec/jkdns
def add_dnspod_record_lib(domain_id, name, type, line, value, ttl):
    domain_info = Domain.get_domain_by_domain_id(domain_id)
    if not domain_info:
        return ["false","no this domain"]
    domain_name = domain_info[1]
    tag = 0
    dnspod_domain_list = get_dnspod_domain_list()
    for dnspod_domain in dnspod_domain_list:
        if dnspod_domain['name'] == domain_name:
            tag = 1
            dnspod_domain_id = dnspod_domain['id']
            break
    if tag == 0:
        return ["false", "no this domain in dnspod"]
    result = add_dnspod_record(dnspod_domain_id, name, type, line, value, ttl)
    return result
コード例 #9
0
ファイル: dns_api.py プロジェクト: 360sec/jkdns
def get_domain_line_list_by_domain_name_api():
    tmp_dict = {}
    tmp_dict['success'] = "false"
    if request.method == "POST":
        domain_name = request.form['domain_name']
        domain_info = Domain.get_domain_by_domain_name(domain_name)
        if domain_info:
            if domain_info[2] == "local_bind":
                tmp_dict['success'] = "true"
                tmp_dict['domain_line_list'] = config.LOCAL_BIND_LINE
            elif domain_info[2] == "dnspod":
                tmp_dict['success'] = "true"
                tmp_dict['domain_line_list'] = get_dnspod_domain_list_list_by_domain_id_lib(domain_info[0])
        else:
            tmp_dict['msg'] = "no this domain_name"
    else:
        tmp_dict['msg'] = "no post data"
    return json.dumps(tmp_dict)
コード例 #10
0
ファイル: dns_api.py プロジェクト: 360sec/jkdns
def get_dns_record_by_domain_id_api():
    tmp_dict = {}
    tmp_dict['success'] = "false"
    if request.method == "POST":
        domain_id = request.form['domain_id']
        domain_info = Domain.get_domain_by_domain_id(domain_id)
        if domain_info:
            if domain_info[2] == "local_bind":
                tmp_dict['success'] = "true"
                tmp_dict['dns_record_list'] = get_dns_record_list_by_domain_id_lib(domain_id)
            elif domain_info[2] == "dnspod":
                tmp_dict['success'] = "true"
                tmp_dict['dns_record_list'] = get_dnspod_record_list_by_domain_id_lib(domain_id)
        else:
            tmp_dict['msg'] = "no this domain_name"
    else:
        tmp_dict['msg'] = "no post data"
    return json.dumps(tmp_dict)
コード例 #11
0
ファイル: dnspod_lib.py プロジェクト: 360sec/jkdns
def get_dnspod_domain_list_list_by_domain_id_lib(domain_id):
    domain_info = Domain.get_domain_by_domain_id(domain_id)
    if not domain_info:
        return []
    domain_name = domain_info[1]
    tag = 0
    dnspod_domain_list = get_dnspod_domain_list()
    for dnspod_domain in dnspod_domain_list:
        if dnspod_domain['name'] == domain_name:
            tag = 1
            dnspod_domain_id = dnspod_domain['id']
    if tag == 0:
        return []

    tmp_list = []
    values = {'login_email': config.DNSPOD_USER, 'login_password': config.DNSPOD_PW, 'format': 'json', 'domain_grade': 'D_Free', 'domain_id': dnspod_domain_id} 
    json_data = curl_dnspod(values, "/Record.Line")
    return json_data['lines']
コード例 #12
0
ファイル: manage_api.py プロジェクト: 360sec/jkdns
def add_record_api():
    tmp_dict = {}
    tmp_dict["success"] = "False"
    auth_result = auth_user()
    if not auth_result[0]:
        tmp_dict["msg"] = "no sso auth"
        return json.dumps(tmp_dict)
    else:
        userinfo = auth_result[1]
    if request.method == "POST":
        try:
            domain_id = request.form["domain_id"]
            domain_info = Domain.get_domain_by_domain_id(domain_id)
            name = request.form["name"]
            type = request.form["type"]
            line = request.form["line"]
            line = line.encode("utf-8")
            value = request.form["value"]
            ttl = request.form["ttl"]
            if if_user_id_have_domain_rights(userinfo["user_id"], domain_id):
                Logger.action_log(userinfo["username"] + " add record ")
                if domain_info[2] == "dnspod":
                    result = add_dnspod_record_lib(domain_id, name, type, line, value, ttl)
                    tmp_dict["success"] = result[0]
                    tmp_dict["msg"] = result[1]
                    return json.dumps(tmp_dict)
                elif domain_info[2] == "local_bind":
                    result = add_dns_record_lib(domain_id, name, ttl, type, value, line)
                    tmp_dict["success"] = result[0]
                    print result[1]
                    tmp_dict["msg"] = result[1]
                    return json.dumps(tmp_dict)
            else:
                tmp_dict["msg"] = "no this domain rights"
                return json.dumps(tmp_dict)
        except Exception, e:
            print e
            tmp_dict["msg"] = "unknown error"
            return json.dumps(tmp_dict)