mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2025-07-01 13:25:08 +03:00
Compare commits
12 Commits
ea0302cb2c
...
32414d39de
Author | SHA1 | Date | |
---|---|---|---|
|
32414d39de | ||
|
e1ec3d42e5 | ||
|
6e9247fff1 | ||
|
80179d5cc5 | ||
|
2265435d62 | ||
|
b4916f20af | ||
|
260bc09276 | ||
|
10a2806f12 | ||
|
e2e8193495 | ||
|
71b6aa7a8c | ||
|
a8bc827706 | ||
|
a366bdbf02 |
@ -13,10 +13,10 @@ FreeBSD_task:
|
||||
freebsd_instance:
|
||||
image_family: freebsd-14-2
|
||||
prepare_script:
|
||||
- pkg install -y pkgconf cmake git libsodium $SSL
|
||||
- pkg install -y pkgconf cmake git libsodium cpu_features $SSL
|
||||
- git submodule update --init --recursive
|
||||
configure_script:
|
||||
- ./configure
|
||||
- CMAKE_FLAGS="-DUSE_SYSTEM_CPU_FEATURES=1" CFLAGS="-I/usr/local/include/cpu_features" ./configure
|
||||
build_script:
|
||||
- make -j $(sysctl -n hw.ncpu || echo 4) -C build
|
||||
test_script:
|
||||
|
4
.github/workflows/fedora-rawhide.yml
vendored
4
.github/workflows/fedora-rawhide.yml
vendored
@ -25,10 +25,10 @@ jobs:
|
||||
submodules: true
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
dnf -y install git cmake ncurses-devel openssl-devel-engine libsodium-devel readline-devel zlib-devel gcc-c++ clang
|
||||
dnf -y install git cmake ncurses-devel openssl-devel-engine libsodium-devel readline-devel zlib-devel gcc-c++ clang google-cpu_features-devel
|
||||
- name: Compile with ${{ matrix.cc }}
|
||||
run: |
|
||||
export CC=${{ matrix.cc }}
|
||||
./configure
|
||||
CMAKE_FLAGS="-DUSE_SYSTEM_CPU_FEATURES=1" CFLAGS="-I/usr/include/cpu_features" ./configure
|
||||
make -C build
|
||||
|
||||
|
@ -2,4 +2,4 @@ SoftEther VPN ("SoftEther" means "Software Ethernet") is an open-source cross-pl
|
||||
Its protocol is very fast and it can be used in very restricted environments, as it's able to transfer packets over DNS and ICMP.
|
||||
The server includes a free Dynamic DNS service, which can be used to access the server even if the public IP address changes.
|
||||
A NAT-Traversal function is also available, very useful in case the required ports cannot be opened on the firewall.
|
||||
The supported third party protocols are OpenVPN, L2TP/IPSec and SSTP.
|
||||
The supported third party protocols are OpenVPN, L2TP/IPSec, SSTP and WireGuard.
|
||||
|
@ -30,6 +30,7 @@
|
||||
<ul>
|
||||
<li>Older versions of SoftEther VPN before June 2019 don't support JSON-RPC APIs.</li>
|
||||
<li>If you want to completely disable the JSON-RPC on your VPN Server, set the <code>DisableJsonRpcWebApi</code> variable to <code>true</code> on the <code>vpn_server.config</code>.</li>
|
||||
<li>You may also restrict access to JSON-RPC API to a specific subnet, e.g. your internal network, by setting the <code>JsonRpcWebApiAllowedSubnet</code> variable to, for example, <code>192.168.0.0/16</code>.</li>
|
||||
</ul>
|
||||
<h3 id="json-rpc-specification">JSON-RPC specification</h3>
|
||||
<p>You must use HTTPS 1.1 <code>POST</code> method to call each of JSON-RPC APIs.<br />
|
||||
|
@ -25,6 +25,7 @@ https://<vpn_server_hostname>:<port>/api/
|
||||
|
||||
- Older versions of SoftEther VPN before June 2019 don't support JSON-RPC APIs.
|
||||
- If you want to completely disable the JSON-RPC on your VPN Server, set the `DisableJsonRpcWebApi` variable to `true` on the `vpn_server.config`.
|
||||
- You may also restrict access to JSON-RPC API to a specific subnet, e.g. your internal network, by setting the `JsonRpcWebApiAllowedSubnet` variable to, for example, `192.168.0.0/16`.
|
||||
|
||||
|
||||
### JSON-RPC specification
|
||||
|
@ -25,6 +25,7 @@ https://<vpn_server_hostname>:<port>/api/
|
||||
|
||||
- Older versions of SoftEther VPN before June 2019 don't support JSON-RPC APIs.
|
||||
- If you want to completely disable the JSON-RPC on your VPN Server, set the `DisableJsonRpcWebApi` variable to `true` on the `vpn_server.config`.
|
||||
- You may also restrict access to JSON-RPC API to a specific subnet, e.g. your internal network, by setting the `JsonRpcWebApiAllowedSubnet` variable to, for example, `192.168.0.0/16`.
|
||||
|
||||
|
||||
### JSON-RPC specification
|
||||
|
@ -1,8 +1,7 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
softether:
|
||||
image: softethervpn/vpnserver:latest
|
||||
hostname: softethervpnserver
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
restart: always
|
||||
|
@ -127,6 +127,9 @@ if(UNIX)
|
||||
if(SE_PIDDIR)
|
||||
add_definitions(-DSE_PIDDIR="${SE_PIDDIR}")
|
||||
endif()
|
||||
|
||||
# Use system libraries instead of bundled
|
||||
set(USE_SYSTEM_CPU_FEATURES false CACHE BOOL "Use system cpu_features")
|
||||
endif()
|
||||
|
||||
# Cedar communication module
|
||||
|
@ -5740,6 +5740,7 @@ bool ServerDownloadSignature(CONNECTION *c, char **error_detail_str)
|
||||
UINT num = 0, max = 19;
|
||||
SERVER *server;
|
||||
char *vpn_http_target = HTTP_VPN_TARGET2;
|
||||
bool disableJsonRpcWebApi;
|
||||
// Validate arguments
|
||||
if (c == NULL)
|
||||
{
|
||||
@ -5750,6 +5751,15 @@ bool ServerDownloadSignature(CONNECTION *c, char **error_detail_str)
|
||||
|
||||
s = c->FirstSock;
|
||||
|
||||
disableJsonRpcWebApi = server->DisableJsonRpcWebApi;
|
||||
if (!disableJsonRpcWebApi && !IsZeroIP(&server->JsonRpcWebApiAllowedSubnetAddr)
|
||||
&& !IsZeroIP(&server->JsonRpcWebApiAllowedSubnetMask)) {
|
||||
// restrict JSON-RPC Web API to specified subnet only
|
||||
if (!IsInSameNetwork(&s->RemoteIP, &server->JsonRpcWebApiAllowedSubnetAddr, &server->JsonRpcWebApiAllowedSubnetMask)) {
|
||||
disableJsonRpcWebApi = true;
|
||||
}
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
bool not_found_error = false;
|
||||
@ -5782,7 +5792,7 @@ bool ServerDownloadSignature(CONNECTION *c, char **error_detail_str)
|
||||
// Receive the data since it's POST
|
||||
data_size = GetContentLength(h);
|
||||
|
||||
if (server->DisableJsonRpcWebApi == false)
|
||||
if (disableJsonRpcWebApi == false)
|
||||
{
|
||||
if (StrCmpi(h->Target, "/api") == 0 || StrCmpi(h->Target, "/api/") == 0)
|
||||
{
|
||||
@ -5868,7 +5878,7 @@ bool ServerDownloadSignature(CONNECTION *c, char **error_detail_str)
|
||||
}
|
||||
else if (StrCmpi(h->Method, "OPTIONS") == 0)
|
||||
{
|
||||
if (server->DisableJsonRpcWebApi == false)
|
||||
if (disableJsonRpcWebApi == false)
|
||||
{
|
||||
if (StrCmpi(h->Target, "/api") == 0 || StrCmpi(h->Target, "/api/") == 0 || StartWith(h->Target, "/admin"))
|
||||
{
|
||||
@ -5939,7 +5949,7 @@ bool ServerDownloadSignature(CONNECTION *c, char **error_detail_str)
|
||||
BUF *b = NULL;
|
||||
*error_detail_str = "HTTP_ROOT";
|
||||
|
||||
if (server->DisableJsonRpcWebApi == false)
|
||||
if (disableJsonRpcWebApi == false)
|
||||
{
|
||||
b = ReadDump("|wwwroot/index.html");
|
||||
}
|
||||
@ -6019,7 +6029,7 @@ bool ServerDownloadSignature(CONNECTION *c, char **error_detail_str)
|
||||
|
||||
if (b == false)
|
||||
{
|
||||
if (server->DisableJsonRpcWebApi == false)
|
||||
if (disableJsonRpcWebApi == false)
|
||||
{
|
||||
if (StartWith(h->Target, "/api?") || StartWith(h->Target, "/api/") || StrCmpi(h->Target, "/api") == 0)
|
||||
{
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "Mayaqua/Internat.h"
|
||||
#include "Mayaqua/Memory.h"
|
||||
#include "Mayaqua/Microsoft.h"
|
||||
#include "Mayaqua/Network.h"
|
||||
#include "Mayaqua/Object.h"
|
||||
#include "Mayaqua/OS.h"
|
||||
#include "Mayaqua/Pack.h"
|
||||
@ -6032,6 +6033,15 @@ void SiLoadServerCfg(SERVER *s, FOLDER *f)
|
||||
// Disable JSON-RPC Web API
|
||||
s->DisableJsonRpcWebApi = CfgGetBool(f, "DisableJsonRpcWebApi");
|
||||
|
||||
char tmpaddr[MAX_PATH];
|
||||
if (CfgGetStr(f, "JsonRpcWebApiAllowedSubnet", tmpaddr, sizeof(tmpaddr))) {
|
||||
IP _subnet, _mask;
|
||||
if (ParseIpAndMask46(tmpaddr, &_subnet, &_mask)) {
|
||||
s->JsonRpcWebApiAllowedSubnetAddr = _subnet;
|
||||
s->JsonRpcWebApiAllowedSubnetMask = _mask;
|
||||
}
|
||||
}
|
||||
|
||||
// Bits of Diffie-Hellman parameters
|
||||
c->DhParamBits = CfgGetInt(f, "DhParamBits");
|
||||
if (c->DhParamBits == 0)
|
||||
@ -6365,6 +6375,11 @@ void SiWriteServerCfg(FOLDER *f, SERVER *s)
|
||||
|
||||
// Disable JSON-RPC Web API
|
||||
CfgAddBool(f, "DisableJsonRpcWebApi", s->DisableJsonRpcWebApi);
|
||||
|
||||
char tmpaddr[MAX_PATH];
|
||||
IPAndMaskToStr(tmpaddr, sizeof(tmpaddr),
|
||||
&s->JsonRpcWebApiAllowedSubnetAddr, &s->JsonRpcWebApiAllowedSubnetMask);
|
||||
CfgAddStr(f, "JsonRpcWebApiAllowedSubnet", tmpaddr);
|
||||
}
|
||||
Unlock(c->lock);
|
||||
}
|
||||
|
@ -276,6 +276,9 @@ struct SERVER
|
||||
IP ListenIP; // Listen IP
|
||||
bool StrictSyslogDatetimeFormat; // Make syslog datetime format strict RFC3164
|
||||
bool DisableJsonRpcWebApi; // Disable JSON-RPC Web API
|
||||
|
||||
IP JsonRpcWebApiAllowedSubnetAddr; // If set, allow access to JSON-RPC Web API from
|
||||
IP JsonRpcWebApiAllowedSubnetMask; // this subnet only
|
||||
};
|
||||
|
||||
|
||||
|
2
src/Mayaqua/3rdparty/cpu_features
vendored
2
src/Mayaqua/3rdparty/cpu_features
vendored
@ -1 +1 @@
|
||||
Subproject commit 26133d3b620c2c27f31d571efd27371100f891e9
|
||||
Subproject commit ba4bffa86cbb5456bdb34426ad22b9551278e2c0
|
@ -109,8 +109,21 @@ if(UNIX)
|
||||
$<$<BOOL:${LIB_RT}>:${LIB_RT}>
|
||||
)
|
||||
|
||||
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(armv7l|aarch64|s390x)$" OR NOT HAVE_SYS_AUXV OR SKIP_CPU_FEATURES)
|
||||
if (NOT HAVE_SYS_AUXV OR SKIP_CPU_FEATURES)
|
||||
add_definitions(-DSKIP_CPU_FEATURES)
|
||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(amd64|i386)")
|
||||
message("cpu_features is not available on FreeBSD/${CMAKE_SYSTEM_PROCESSOR}")
|
||||
add_definitions(-DSKIP_CPU_FEATURES)
|
||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" AND NOT CMAKE_SYSTEM_NAME MATCHES "^(arm64|x86_64)")
|
||||
# macOS runs only on Intel or ARM architecrues, should not reach here
|
||||
add_definitions(-DSKIP_CPU_FEATURES)
|
||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS" OR ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
|
||||
message("cpu_features is not available on ${CMAKE_SYSTEM_NAME}")
|
||||
add_definitions(-DSKIP_CPU_FEATURES)
|
||||
elseif(USE_SYSTEM_CPU_FEATURES)
|
||||
CHECK_INCLUDE_FILE(cpu_features_macros.h HAVE_CPU_FEATURES)
|
||||
message("-- Using system's cpu_features")
|
||||
target_link_libraries(mayaqua PRIVATE cpu_features)
|
||||
else()
|
||||
add_subdirectory(3rdparty/cpu_features)
|
||||
set_property(TARGET cpu_features PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
|
@ -6993,6 +6993,18 @@ void IPToStr6Inner(char *str, IP *ip)
|
||||
}
|
||||
}
|
||||
|
||||
// Format IP and subnet mask as "<ip>/<masksize>"
|
||||
void IPAndMaskToStr(char *str, UINT size, IP *ip, IP *subnet)
|
||||
{
|
||||
int iplen;
|
||||
UINT masksize;
|
||||
|
||||
IPToStr(str, size, ip);
|
||||
iplen = StrLen(str);
|
||||
masksize = SubnetMaskToInt(subnet);
|
||||
Format(str + iplen, size - iplen, "/%d", masksize);
|
||||
}
|
||||
|
||||
// Convert the string to an IP address
|
||||
bool StrToIP6(IP *ip, char *str)
|
||||
{
|
||||
|
@ -1293,6 +1293,7 @@ void IPToStr6(char *str, UINT size, IP *ip);
|
||||
void IP6AddrToStr(char *str, UINT size, IPV6_ADDR *addr);
|
||||
void IPToStr6Array(char *str, UINT size, UCHAR *bytes);
|
||||
void IPToStr6Inner(char *str, IP *ip);
|
||||
void IPAndMaskToStr(char *str, UINT size, IP *ip, IP *subnet);
|
||||
void IntToSubnetMask6(IP *ip, UINT i);
|
||||
void IPAnd6(IP *dst, IP *a, IP *b);
|
||||
void GetAllRouterMulticastAddress6(IP *ip);
|
||||
|
Loading…
Reference in New Issue
Block a user