예제 #1
0
파일: server.py 프로젝트: WrongChao/pritunl
def server_client_connect_post(server_id):
    org_id = flask.request.json["org_id"]
    user_id = flask.request.json["user_id"]

    server = Server(server_id)
    if not server:
        return utils.jsonify({"error": SERVER_INVALID, "error_msg": SERVER_INVALID_MSG}, 401)
    org = server.get_org(org_id)
    if not org:
        return utils.jsonify({"error": ORG_INVALID, "error_msg": ORG_INVALID_MSG}, 401)
    user = org.get_user(user_id)
    if not user:
        return utils.jsonify({"error": USER_INVALID, "error_msg": USER_INVALID_MSG}, 401)
    if user.type != CERT_CLIENT:
        return utils.jsonify({"error": USER_TYPE_INVALID, "error_msg": USER_TYPE_INVALID_MSG}, 401)

    local_ip_addr, remote_ip_addr = server.get_ip_set(org.id, user_id)
    if local_ip_addr and remote_ip_addr:
        client_conf = "ifconfig-push %s %s" % (local_ip_addr, remote_ip_addr)
    else:
        client_conf = ""

    return utils.jsonify({"client_conf": client_conf})
예제 #2
0
파일: server.py 프로젝트: bitland/pritunl
def server_client_connect_post(server_id):
    org_id = flask.request.json['org_id']
    user_id = flask.request.json['user_id']

    server = Server(server_id)
    if not server:
        return utils.jsonify({
            'error': SERVER_INVALID,
            'error_msg': SERVER_INVALID_MSG,
        }, 401)
    org = server.get_org(org_id)
    if not org:
        return utils.jsonify({
            'error': ORG_INVALID,
            'error_msg': ORG_INVALID_MSG,
        }, 401)
    user = org.get_user(user_id)
    if not user:
        return utils.jsonify({
            'error': USER_INVALID,
            'error_msg': USER_INVALID_MSG,
        }, 401)
    if user.type != CERT_CLIENT:
        return utils.jsonify({
            'error': USER_TYPE_INVALID,
            'error_msg': USER_TYPE_INVALID_MSG,
        }, 401)

    local_ip_addr, remote_ip_addr = server.get_ip_set(org.id, user_id)
    if local_ip_addr and remote_ip_addr:
        client_conf = 'ifconfig-push %s %s' % (local_ip_addr, remote_ip_addr)
    else:
        client_conf = ''

    return utils.jsonify({
        'client_conf': client_conf,
    })