All Projects → chanyipiaomiao → pritunl-http-api

chanyipiaomiao / pritunl-http-api

Licence: other
Pritunl OpenVPN HTTP API

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to pritunl-http-api

terraform-aws-pritunl-vpn-server
Pritunl VPN Server for your public/private like VPC on AWS
Stars: ✭ 40 (+53.85%)
Mutual labels:  openvpn, pritunl
droidovpn
An unofficial VPN Gate client for Android.
Stars: ✭ 65 (+150%)
Mutual labels:  openvpn
2cca
2-cent Certification Authority
Stars: ✭ 27 (+3.85%)
Mutual labels:  openvpn
terraform-openvpn
A sample terraform setup for OpenVPN using Let's Encrypt and Certbot to generate certificates
Stars: ✭ 43 (+65.38%)
Mutual labels:  openvpn
Cybernet-VPN
Android Cybernet VPN App
Stars: ✭ 28 (+7.69%)
Mutual labels:  openvpn
ovpn2onc
Convert OpenVPN config files to the ONC ChromeOS network config files.
Stars: ✭ 27 (+3.85%)
Mutual labels:  openvpn
beego-vuejs-starter-kit
Beego (GOLANG), Webpack, Sass, Vue.js, Vuex, Buefy
Stars: ✭ 32 (+23.08%)
Mutual labels:  beego
openvpn
Build your own private VPN server. OpenVPN, Scramblesuit and DNS up in less then 5 minutes
Stars: ✭ 78 (+200%)
Mutual labels:  openvpn
desktop-app-cli
Official IVPN command-line interface (CLI)
Stars: ✭ 18 (-30.77%)
Mutual labels:  openvpn
ShadowOVPN
ShadowOVPN bridges shadowsocks and OpenVPN based on Docker. You can now connect to OpenVPN servers with any shadowsocks compatible client.
Stars: ✭ 17 (-34.62%)
Mutual labels:  openvpn
vpnman
A web-based frontend for OpenVPN server management
Stars: ✭ 32 (+23.08%)
Mutual labels:  openvpn
beego-admin
基于beego v2.0.1框架和AdminLte前端框架,开发的go语言通用后台系统,在beego v2.0.1框架的基础上,封装了后台系统的分页功能,excel数据导出功能等丰富常用的扩展,MVC模式,使用原生的html原生作为前端显示,更加的灵活自由。beego-admin v2.0.1通用的后台系统真正的做到了开箱即用,欢迎大家使用。
Stars: ✭ 89 (+242.31%)
Mutual labels:  beego
ToBeAdmin
beego 与 Ant Design Pro Vue 基础权限系统
Stars: ✭ 38 (+46.15%)
Mutual labels:  beego
AutoScriptVPS
VPN AutoScript
Stars: ✭ 59 (+126.92%)
Mutual labels:  openvpn
arch-privoxyvpn
Docker build script for Arch Linux base with Privoxy and OpenVPN
Stars: ✭ 55 (+111.54%)
Mutual labels:  openvpn
desktop-app-ui
Official IVPN Desktop app (legacy version)
Stars: ✭ 23 (-11.54%)
Mutual labels:  openvpn
openvpn-aws-tf-ansible
OpenVPN with Terraform and Ansible on AWS
Stars: ✭ 17 (-34.62%)
Mutual labels:  openvpn
ConsolePi
Raspberry Pi Based Serial Console Server, with PushBullet Notification of IP changes, Automatic VPN termination, custom menu, Power Outlet Control, and a lot more
Stars: ✭ 109 (+319.23%)
Mutual labels:  openvpn
iit-kgp-network
Information repository and Solutions on IIT KGP Internet Problems.
Stars: ✭ 28 (+7.69%)
Mutual labels:  openvpn
ancistrus
Netgear's D7000 Nighthawk Router Experience Distributed Project
Stars: ✭ 61 (+134.62%)
Mutual labels:  openvpn

Pritunl HTTP API

Pritunl 是一个基于OpenVPN协议实现的企业级VPN方案, 免费版本可以拥有一个服务器的创建, 付费版有更多的功能.

安装配置文档

由于开源版不提供API调用,故有此项目, 通过模拟登陆的方式实现的一套HTTP API接口

安装运行

下载二进制文件即可

配置文件

# 配置文件中的${},首先从环境变量获取,获取不到则使用后边的默认值

appname = pritunl-http-api
autorender = false
copyrequestbody = true
EnableDocs = false

# 运行模式 dev | prod
runmode = "${PRITUNL_HTTP_API_RUNMODE||dev}"

# 监听地址
httpaddr = "${PRITUNL_HTTP_API_LISTEN_IP||127.0.0.1}"

# 监听端口
httpport = "${PRITUNL_HTTP_API_PORT||30080}"

[log]
# 日志路径
logPath = "${PRITUNL_HTTP_API_LOGPATH||logs/pritunl.log}"

[security]
# 是否启用token认证,启用会要求在请求头部加入token头

# true | false
enableToken = false

# 请求头中 token头名称
tokenName = "${PRITUNL_HTTP_API_TOKEN_NAME||PRITUNL-HTTP-API-TOKEN}"

# token 值
token = "${PRITUNL_HTTP_API_TOKEN||CyNINFvjdJTh4QTfqsPVJuNdRDUGvHnU}"


[common-vpn-wenba]
# common 是一个标识,代表的是那台服务器,可以随意定义, 比如有多台pritunl服务器,在调接口的时候会用到
# wenba 是pritunl里面一个organization的名称, pritunl里面可以包含多个organization, 在调接口的时候会用到
# common-vpn-wenba 三者结合起来指的就是要操作那台服务器的那个organization

# url是pritunl控制台地址
url = "${PRITUNL_COMMON_URL||https://x.x.x.x}"

# 登录的用户名和密码
username = "${PRITUNL_COMMON_USERNAME||wenba}"
password = "${PRITUNL_COMMON_PASSWORD||123456}"

# organization id 是对应上边wenba
organization = "${PRITUNL_COMMON_WENBA_ORG||123456}"

# debug 用于调试
# true | false
debug = "${PRITUNL_COMMON_DEBUG||false}"

如何获取 organization 的 名称 和 id?

先登录到pritunl web 控制台

chrome可以通过按F12或者右键检查菜单打开开发者工具,监控Network

切换到 Users 选项卡, 找到该接口的响应

/organization?page=0

里面有组织的名称和ID,在调用接口的时候会需要用到这2个值

接口

添加用户

POST /pritunl?vpn-name=VPN名称&org-name=组织名称&username=用户名

vpn-name 就是配置文件里面配置的名称, 如: common
org-name organization组织的名称, 如: wenba
username 用户名
email 可选

通过 vpn-name 和 org-name 在配置文件中找到对应的配置

返回

{
    "data": {
        "profileLink": "https://x.x.x.x/k/u3yUsEcL",
        "userId": "5d008e164ed924023806d388",
        "username": "test7777"
    },
    "entryType": "Pritunl OpenVPN Operation",
    "error": "",
    "statusCode": 0
}

profileLink 是下载配置文件的和配置2步验证的URL

删除用户

DELETE /pritunl?vpn-name=VPN名称&org-name=组织名称&username=用户名

返回

{
    "data": {
        "status": "deleted",
        "username": "test7777"
    },
    "entryType": "Pritunl OpenVPN Operation",
    "error": "",
    "statusCode": 0
}

禁用用户

PUT /pritunl?vpn-name=VPN名称&org-name=组织名称&username=用户名&status=disable

返回

{
    "data": {
        "status": "disabled",
        "username": "test7777"
    },
    "entryType": "Pritunl OpenVPN Operation",
    "error": "",
    "statusCode": 0
}

启用用户

PUT /pritunl?vpn-name=VPN名称&org-name=组织名称&username=用户名&status=enable

返回

{
    "data": {
        "status": "enabled",
        "username": "test7777"
    },
    "entryType": "Pritunl OpenVPN Operation",
    "error": "",
    "statusCode": 0
}

批量添加用户

POST /pritunl?vpn-name=VPN名称&org-name=组织名称&username=用户名&multi=yes

json请求体

请求头: Content-Type application/json

[
	{
		"name": "test5555",
		"email": null
	},
	{
		"name": "test6666",
		"email": null
	}
]

返回

{
    "data": [
        {
            "profileLink": "https://x.x.x.x/k/aP25mrUn",
            "userId": "5cff8b174ed92402380625f7",
            "username": "test5555"
        },
        {
            "profileLink": "https://x.x.x.x/k/x47p83KG",
            "userId": "5cff8b974ed924023806264f",
            "username": "test6666"
        }
    ],
    "entryType": "Pritunl OpenVPN Operation",
    "error": "",
    "statusCode": 0
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].