Giter Site home page Giter Site logo

realm's Introduction

Realm

A simple, high performance relay server written in rust.

realm realm downloads

Libs

lib doc
realm-core crates.io Released API docs
realm-io crates.io Released API docs
realm-lb crates.io Released API docs
realm-hook crates.io Released API docs
realm-syscall crates.io Released API docs

Features

  • Zero configuration. Setup and run in one command.
  • Concurrency. Bidirectional concurrent traffic leads to high performance.
  • Low resources cost.

Container

Realm can be run in a container with OCI (like Docker, Podman, Kubernetes, etc), see guides here.

Build

Install rust toolchain with rustup:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Clone this repository:

git clone https://github.com/zhboner/realm && cd realm

Build:

cargo build --release

You can also pass target_cpu=native to allow more possible optimizations:

RUSTFLAGS='-C target_cpu=native' cargo build --release

The realm binary will be available in target/release.

Build Options

  • udp: enable udp relay builtin.
  • tfo: enable tcp-fast-open deprecated.
  • trust-dns: enable trust-dns's async dns resolver builtin.
  • zero-copy: enable zero-copy on linux builtin.
  • brutal-shutdown: see realm_io/brutal-shutdown.
  • hook: see realm_hook.
  • proxy: enable proxy-protocol.
  • balance: enable load balance.
  • transport: enable ws/tls/wss.
  • batched-udp: enable more efficient udp on linux.
  • multi-thread: enable tokio's multi-threaded IO scheduler.
  • mi-malloc: custom memory allocator.
  • jemalloc: custom memory allocator.
  • page-alloc: custom memory allocator.

Default: proxy + balance + transport + batched-udp + brutal-shutdown + multi-thread.

See also: Cargo.toml.

Examples:

# simple tcp
cargo build --release --no-default-features

# enable other options
cargo build --release --features 'jemalloc'

# fully customized
cargo build --release
    --no-default-features
    --features 'transport, multi-thread, jemalloc'

Cross Compile

Please refer to https://rust-lang.github.io/rustup/cross-compilation.html. You may need to install cross-compilers or other SDKs, and specify them when building the project.

Or have a look at Cross, it makes things easier.

Usage

A high efficiency relay tool

Usage: realm [FLAGS] [OPTIONS]

Commands:
  convert  convert your legacy configuration into an advanced one

FLAGS:
  -h, --help     show help
  -v, --version  show version
  -d, --daemon   run as a unix daemon
  -u, --udp      force enable udp forward
  -t, --ntcp     force disable tcp forward
  -6, --ipv6     force disable ipv6 mapped ipv4
  -f, --tfo      force enable tcp fast open -- deprecated
  -z, --splice   force enable tcp zero copy -- deprecated

OPTIONS:
  -c, --config <path>               use config file
  -l, --listen <address>            listen address
  -r, --remote <address>            remote address
  -x, --through <address>           send through ip or address
  -i, --interface <device>          bind to interface
  -a, --listen-transport <options>  listen transport
  -b, --remote-transport <options>  remote transport

SYS OPTIONS:
  -n, --nofile <limit>        set nofile limit
  -p, --pipe-page <number>    set pipe capacity
  -j, --pre-conn-hook <path>  set pre-connect hook

LOG OPTIONS:
      --log-level <level>  override log level
      --log-output <path>  override log output

DNS OPTIONS:
      --dns-mode <mode>          override dns mode
      --dns-min-ttl <second>     override dns min ttl
      --dns-max-ttl <second>     override dns max ttl
      --dns-cache-size <number>  override dns cache size
      --dns-protocol <protocol>  override dns protocol
      --dns-servers <servers>    override dns servers

PROXY OPTIONS:
      --send-proxy <send_proxy>        send proxy protocol header
      --send-proxy-version <version>   send proxy protocol version
      --accept-proxy <accept_proxy>    accept proxy protocol header
      --accept-proxy-timeout <second>  accept proxy protocol timeout

TIMEOUT OPTIONS:
      --tcp-timeout <second>         override tcp timeout(5s)
      --udp-timeout <second>         override udp timeout(30s)
      --tcp-keepalive <second>       override default tcp keepalive interval(15s)
      --tcp-keepalive-probe <count>  override default tcp keepalive count(3)

Start from command line arguments:

realm -l 0.0.0.0:5000 -r 1.1.1.1:443

Start with a config file:

# use toml
realm -c config.toml

# use json
realm -c config.json

Start with environment variables:

REALM_CONF='{"endpoints":[{"local":"127.0.0.1:5000","remote":"1.1.1.1:443"}]}' realm

# or
export REALM_CONF=`cat config.json | jq -c `
realm

Convert a legacy config file:

realm convert old.json

Configuration

TOML Example

[log]
level = "warn"
output = "/var/log/realm.log"

[network]
no_tcp = false
use_udp = true

[[endpoints]]
listen = "0.0.0.0:5000"
remote = "1.1.1.1:443"

[[endpoints]]
listen = "0.0.0.0:10000"
remote = "www.google.com:443"
JSON Example

{
  "log": {
    "level": "warn",
    "output": "/var/log/realm.log"
  },
  "network": {
    "no_tcp": false,
    "use_udp": true
  },
  "endpoints": [
    {
      "listen": "0.0.0.0:5000",
      "remote": "1.1.1.1:443"
    },
    {
      "listen": "0.0.0.0:10000",
      "remote": "www.google.com:443"
    }
  ]
}

See more examples here.

Overview

├── log
│   ├── level
│   └── output
├── dns
│   ├── mode
│   ├── protocol
│   ├── nameservers
│   ├── min_ttl
│   ├── max_ttl
│   └── cache_size
├── network
│   ├── no_tcp
│   ├── use_udp
│   ├── ipv6_only
│   ├── tcp_timeout
│   ├── udp_timeout
│   ├── tcp_keepalive
│   ├── tcp_keepalive_probe
│   ├── send_proxy
│   ├── send_proxy_version
│   ├── accept_proxy
│   └── accept_proxy_timeout
└── endpoints
    ├── listen
    ├── remote
    ├── extra_remotes
    ├── balance
    ├── through
    ├── interface
    ├── listen_transport
    ├── remote_transport
    └── network->

You should provide at least endpoint.listen and endpoint.remote, the left fields will take their default values.

Option priority: cmd override > endpoint config > global config.

endpoint

endpoint.listen: string

Local address, supported formats:

  • ipv4:port
  • ipv6:port

endpoint.remote: string

Remote address, supported formats:

  • ipv4:port
  • ipv6:port
  • example.com:port

endpoint.extra_remotes: string array

Extra remote address, same as endpoint.remote above.

endpoint.balance: string

Require balance feature.

Load balance strategy and weights of remote peers.

Format:

$strategy: $weight1, $weight2, ...

Where remote is used as default backend server, and extra_remotes are used as backups.

Available algorithms (provided by realm_lb):

  • iphash

  • roundrobin

Example:

[[endpoints]]
remote = "a:443"
extra_remotes = ["b:443", "c:443"]
balance = "roundrobin: 4, 2, 1"

The weight of [a, b, c] is [4, 2, 1] in turn.

endpoint.through: string

TCP: Bind a specific ip before opening a connection.

UDP: Bind a specific ip or address before sending packet.

Supported formats:

  • ipv4/ipv6 (tcp/udp)
  • ipv4/ipv6:port (udp)

endpoint.interface: string

Bind to a specific interface.

endpoint.listen_transport: string

Require transport feature.

See Kaminari Options.

endpoint.remote_transport: string

Require transport feature.

See Kaminari Options.

endpoint.network

The same as network, override global options.

log

log.level: string

values:

  • off
  • error
  • warn
  • info
  • debug
  • trace

default: off

log.output: string

values:

  • stdout
  • stderr
  • path (e.g. /var/log/realm.log)

default: stdout

dns

Require trust-dns feature.

dns.mode: string

Dns resolve strategy.

values:

  • ipv4_only
  • ipv6_only
  • ipv4_then_ipv6
  • ipv6_then_ipv4
  • ipv4_and_ipv6

default: ipv4_and_ipv6

dns.protocol: string

Dns transport protocol.

values:

  • tcp
  • udp
  • tcp_and_udp

default: tcp_and_udp

dns.nameservers: string array

Custom upstream servers.

format: ["server1", "server2" ...]

default:

If on unix/windows, read from the default location.(e.g. /etc/resolv.conf).

Otherwise, use google's public dns(8.8.8.8:53, 8.8.4.4:53 and 2001:4860:4860::8888:53, 2001:4860:4860::8844:53).

dns.min_ttl: unsigned int

The minimum lifetime of a positive dns cache.

default: 0

dns.max_ttl: unsigned int

The maximum lifetime of a positive dns cache.

default: 86400 (1 day)

dns.cache_size: unsigned int

The maximum count of dns cache.

default: 32

network

network.no_tcp: bool

Do not start a tcp relay.

default: false

network.use_udp: bool

Require udp feature

Start listening on a udp endpoint and forward packets to the remote peer.

It will dynamically allocate local endpoints and establish udp associations. Once timeout, the endpoints will be deallocated and the association will be terminated. See also: network.udp_timeout.

Due to the receiver side not limiting access to the association, the relay works like a full-cone NAT.

default: false

network.ipv6_only: bool

Disable ipv4-mapped-ipv6 when binding to an ipv6 address.

E.g.: [::0]:port with (ipv6_only=false) binds to *:port

[::0]:port with (ipv6_only=true) binds to [::]:port

default: false

network.zero_copy: bool deprecated

Require zero-copy feature.

Use splice instead of send/recv while handing tcp connection. This will save a lot of memory copies and context switches.

default: false

network.fast_open: bool deprecated

Require fast-open feature.

It is not recommended to enable this option, see The Sad Story of TCP Fast Open.

default: false

network.tcp_timeout: unsigned int

This is connect timeout. An attempt to connect to a remote peer fails after waiting for a period of time.

To disable timeout, you need to explicitly set timeout value to 0.

default: 5

network.udp_timeout: unsigned int

Terminate udp association after timeout.

The timeout value must be properly configured in case of memory leak. Do not use a large timeout!

default: 30

network.tcp_keepalive: unsigned int

TCP Keepalive interval.

On Linux, this is equivalent to setting both net.ipv4.tcp_keepalive_time and net.ipv4.tcp_keepalive_intvl.

To use system's tcp keepalive interval, you need to explicitly set this option to 0.

default: 15

network.tcp_keepalive_probe: unsigned int

TCP Keepalive retries.

On Linux, this is equivalent to ipv4.tcp_keepalive_probes.

default: 3

network.send_proxy: bool

Require proxy feature.

Send haproxy PROXY header once the connection established. Both v1 and v2 are supported, see send_proxy_version.

You should make sure the remote peer also speaks proxy-protocol.

default: false

network.send_proxy_version: unsigned int

Require proxy feature.

This option has no effect unless send_proxy is enabled.

value:

  • 1
  • 2

default: 2

network.accept_proxy: bool

Require proxy feature.

Wait for a PROXY header once the connection established.

If the remote sender does not send a v1 or v2 header before other contents, the connection will be closed.

default: false

network.accept_timeout: unsigned int

Require proxy feature.

Wait for a PROXY header within a period of time, otherwise close the connection.

default: 5.

realm's People

Contributors

billzhong avatar howardjohn avatar i18n-now avatar meteorsliu avatar noahziheng avatar sabify avatar soniccube avatar zephyrchien avatar zhboner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

realm's Issues

发布一个windows 的exe

发布一个windows 的exe呀
还有,tcp udp转发能不能分开,提供个选项。

之前用go的项目,
占用cpu 内存太多,

propose to set tcp_nodelay flag

From https://www.extrahop.com/company/blog/2016/tcp-nodelay-nagle-quickack-best-practices/

Enabling the TCP_NODELAY option turns Nagle's algorithm off. In the case of interactive applications or chatty protocols with a lot of handshakes such as SSL, Citrix and Telnet, Nagle's algorithm can cause a drop in performance, whereas enabling TCP_NODELAY can improve the performance.

In any request-response application protocols where request data can be larger than a packet, this can artificially impose a few hundred milliseconds latency between the requester and the responder, even if the requester has properly buffered the request data. Nagle's algorithm should be disabled by enabling TCP_NODELAY by the requester in this case. If the response data can be larger than a packet, the responder should also disable Nagle's algorithm by enabling TCP_NODELAY so the requester can promptly receive the whole response.

Consider we are performing a lot of TLS/HTTP handshakes over Realm, I think it's a good trade-off.

Tokio has provided a convenient API: tokio::net::TcpStream::set_nodelay. To set the TCP_NODELAY socket option, we just need to invoke that fn right after connect() or accept().

Realm got crashed due to panic a few hours later

Describe the bug
Realm got crashed due to panic a few hours later with below message

thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 24, kind: Other, message: "Too many open files" }', src/relay/udp.rs:30:88
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I'm in the process of verifying to get a backtrace...

To Reproduce

  1. Run ./realm -l 0.0.0.0:50000 -r x.x.x.x:50000 (udp)
  2. Get error

Expected behavior
Don't panicking

Screenshots
None

Environment

  • Kernel: Linux version 5.13.12-200.fc34.x86_64 ([email protected]) (gcc (GCC) 11.2.1 20210728 (Red Hat 11.2.1-1), GNU ld version 2.35.2-4.fc34) #1 SMP Wed Aug 18 13:27:18 UTC 2021
  • OS: Fedora release 34 (Thirty Four)
  • rustc: rustc 1.54.0 (Fedora 1.54.0-1.fc34)
  • Cargo: cargo 1.54.0

Additional context
Add any other context about the problem here.

realm v2.2.2使用UDP问题

系统资料:
Distributor ID: Debian
Description: Debian GNU/Linux 10 (buster)
Release: 10
Codename: buster
Linux 5.15.32-xanmod1 x86_64 GNU/Linux

Realm 2.2.2 [proxy][transport][multi-thread]
[CONFIG文件内容]:

[log]
level = "warn"

[network]
use_udp = true
udp_timeout = 30

[[endpoints]]
listen = "0.0.0.0:8888"
remote = "6.7.8.9:3333"
remote_transport = "ws;host=abc.com;path=/wesboot;tls;sni=abc.com"

[[endpoints]]
listen = "0.0.0.0:2222"
remote = "1.2.3.4:5555"

当开启后.出现日志内容:

log: level=warn, output=stdout
dns: mode=ipv4_and_ipv6, protocol=tcp+udp, min-ttl=0, max-ttl=86400, cache-size=32, servers=system
inited: x.x.x.x:xxxx -> x.x.x.x:xxxx; options: udp-forward=on, tcp-fast-open=off, tcp-zero-copy=off; send-proxy=off, send-proxy-version=2, accept-proxy=off, accept-proxy-timeout=5s; tcp-timeout=300s, udp-timeout=30s; transport=kaminari
inited: x.x.x.x:xxxx -> x.x.x.x:xxxx; options: udp-forward=on, tcp-fast-open=off, tcp-zero-copy=off; send-proxy=off, send-proxy-version=2, accept-proxy=off, accept-proxy-timeout=5s; tcp-timeout=300s, udp-timeout=30s; transport=none
thread 'tokio-runtime-worker' panicked at '[udp]unable to bind x.x.x.x:xxxx: Address already in use (os error 98)', /project/src/relay/mod.rs:81:29
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Aborted

[udp]unable to bind x.x.x.x:xxxx: Address already in use对应使用端口已经KILL.

长时间转发会报错

报错信息如下
TCP forward error 域名:端口,No file descriptors available (os error 24)
图片

VIRT 是不是分配的过高了

在虚拟机上测试转发10000-20000端口段,提示 memory allocation of 24 bytes failed
top命令中查看VIRT到了30G多,但实际的占用的内存不是很多
虚拟机的配置是4GBRAM+3GB SWAP,不知道要怎么改可以降低VIRT的分配,不然没办法正常跑起来

运行中异常, 直接退出

thread 'tokio-runtime-worker' panicked at 'called Result::unwrap() on an Err value: AddrParseError(())', src/relay.rs:73:22
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

辛苦了, 谢谢

功能建议

建议加入配置文件,可参考haproxy,有配置文件后期迁移就方便很多了,希望后期加入 Tls ws 转发协议客户端(加密数据)→服务端解密→酸酸乳

端口段转发超过128个端口 cpu飙升

系统:debian 9.13(全新环境可以复现)
配置文件:config.json

{
    "listening_addresses": ["0.0.0.0"],
    "listening_ports": ["10000-10127"],
    "remote_addresses": ["1.2.3.4"],
    "remote_ports": ["10000-10127"]
}

当端口段范围为 1-127 时, cpu 无负载.

截屏2021-01-13 上午3 31 30

当端口段范围为 1-128 时, cpu 单核满载.

截屏2021-01-13 上午3 32 28

功能建议

请问下后期会考虑增加加密转发么?类似于gost这样功能的

使用疑问

是否支持长时间、大流量转发的场景。稳定性如何?

src\relay.rs:100:32 报错

Describe the bug

thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 10022, kind: InvalidInput, message: "提供了一个无效的参数。" }', src\relay.rs:100:32

When this bug was triggered, realm can not relay UDP stream.
Screenshots
image

Desktop :

  • OS: Windows Server 2016
  • Version: The Lastest

Debian 10 64位启动后无反应

Debian 10 64位系统,下载最新版本,给权限后
设置端口转发无反应,检查realm进程占用0内存0CPU,端口检测没有开放
实际转发失败,程序并没有启动

Problem with UDP

As has been mentioned in #21, sometimes UDP forwarding does not work properly.

realm/src/relay.rs

Lines 115 to 131 in 3243f54

match from != remote_socket {
true => {
// forward
sender_vec.push(from);
packet_sender
.send((buf, size, remote_socket.clone()))
.unwrap();
}
false => {
// backward
if sender_vec.len() < 1 {
continue;
}
let client_socket = sender_vec.remove(0);
packet_sender.send((buf, size, client_socket)).unwrap();
}
}

When sending a UDP packet, we need to specify its destination. According to L115-L131, sender_vec stores the SockAddr from a incoming packet(usually from a client) one by one, then consumes them when the response arrives.

However, this would work only under some ideal conditions, where there is only one client sending, and the number of response packets should be the same. Otherwise, the program would drop some of the response packets, or incorrectly send them to another peer, or have the SockAddr left in sender_vec...

Instead of counting the incoming SockAddr one by one, I think we should record the associated pairs of incoming SockAddr and remote SockAddr for a period of time. To deal with multiple clients, maybe we need to allocate a unique local SockAddr for each incoming Sockaddr, and also have it recorded. Finally, the UDP part would work somewhat like a NAT device.

What about spawning less thread?

Thread is expensive. As far as I am concerned, spawning too much threads should be avoided.

In this program, each pair of laddr&raddr creates 4 threads(1tcp, 2udp, 1dns) 2 extra threads. When more pairs added, the resource consumption and the context switch overhead would become unacceptable(#15, #20).

And in most situations, network I/O is the bottleneck. I'm afraid that multi-thread would not help improve the performance, instead the program could be slowed down because of context switching and the use of mutex.

I have replaced thread::spawn with tokio:spawn, and use trust_dns_resolver::TokioAsyncResolver as async dns resolver, would that be OK?

运行时报错

root@ubuntu:~# /usr/bin/realm -l 127.0.0.1:7890 -r x.x.x.x:443
thread 'tokio-runtime-worker' panicked at 'called Result::unwrap() on an Err value: Os { code: 98, kind: AddrInUse, message: "Address in use" }', src/relay.rs:51:69
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

请问这种情况该怎么解决?

UDP转发貌似不正常,NAT错误。

Describe the bug
转发后 TCP 数据没问题,但UDP貌似不正常。转发后使用SSR等程序玩游戏时 显示 NAT错误。

希望能解决一下,感谢!

Realm 无连接的情况下自动死亡

Describe the bug
在启动守护进程的情况下,如果长时间(5-15min)没有连接中转服务器,则会变成inactive,只能通过
systemctl restart realm
命令来手动重启!

系统:
Centos7 与 Ubuntu18 TLS

increase buffer size

tokio::io::copy internally uses a hard-coded buffer(only 2k). It is too small. I would like to extend it to at least 4k, (or 16k which is better), so that a lot of(or maybe a few) syscall could be saved.

And we need to write our own copy fn. It is not complex, just like:

let mut buf = vec![0u8; 0x1000];
let mut n: usize;
loop {
    n = r.read(&mut buf).await?;
    if n==0 { break; }
    w.write(&buf[..n]).await?;
}

f

f

支持TFO

可以用ss-rust作者开源的这个库 tokio-tfo,支持linux/win/bsd,跟ss-rust是相同的实现
建议把这个功能加入到features,默认关闭。有需要的用户可以加上--features tfo 参数自行编译
#13

功能建议

1、增加配置文件,以便支持多端口

2、增加守护进程,避免进程挂掉

an attempt to impl zero-copy

I think it's difficult to be compatible with tokio's AsyncRead/AsyncWrite trait, for that AsyncRead/AsyncWrite uses a &[u8] buffer however splice uses a pipe.

So I've tried another approach. We can still use TcpStream, making use of its inner event loop. Instead of calling read/write, we can firstly get its inner fd via as_raw_fd() (TcpStream impls AsRawFd), then call libc::splice on the fd directly.

The problem is that TcpStream::ready does not clear the readiness on the fd, and there is no public fn to achieve this. I have to invoke TcpStream::try_read/try_write with an empty buffer to consume the read/write event.

Here's the demo
https://github.com/zephyrchien/realm/blob/bfed56a66d7c91126a41a05ad2bac7b92c728f61/src/relay.rs#L134-L215

docker镜像报错: Error response from daemon: Head https://ghcr.io/v2/zhboner/realm/manifests/latest: unauthorized.

大佬你好,realmdocker镜像是不是没有读取权限呢?我直接运行readme示例:

docker run -d -p 9000:9000 ghcr.io/zhboner/realm:latest -l 0.0.0.0:9000 -r 192.168.233.2:9000

会得到如下报错:

Unable to find image 'ghcr.io/zhboner/realm:latest' locally
docker: Error response from daemon: Head https://ghcr.io/v2/zhboner/realm/manifests/latest: unauthorized.
See 'docker run --help'.

Google了一下,说是需要personal access token (PAT)才行,不过我创建了之后,重新拉取镜像,依然是报错:

Error response from daemon: unauthorized

可以支持这种格式吗

{
"listening_addresses": ["0.0.0.0"], #监听IP
"listening_ports": ["20000"],监听端口
"remote_addresses": ["azure.alibaba.com"],#远程地址
"remote_ports": ["20002"]#远程端口
}

{
"listening_addresses": ["0.0.0.0"], #监听IP
"listening_ports": ["20002-30000"],#监听端口
"remote_addresses": ["azure-a.alibaba.com"],#远程地址
"remote_ports": ["20002-30000"]#远程端口
}

可以支持这种配置文件吗 第一个单端口转发 第二个端口段

配置文件支持log吗?

配置文件里只要写上这一段 就无法启动realm
[log]
level = "warn"
output = "/var/log/realm.log"

提示
● realm.service - realm
Loaded: loaded (/etc/systemd/system/realm.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: core-dump) since Mon 2022-04-25 15:39:00 CST; 2s ago
Process: 9710 ExecStart=/etc/realm/realm -c /etc/realm/config.toml (code=dumped, signal=ABRT)
Main PID: 9710 (code=dumped, signal=ABRT)

Apr 25 15:39:00 OLink systemd[1]: realm.service: Main process exited, code=dumped, status=6/ABRT
Apr 25 15:39:00 OLink systemd[1]: realm.service: Failed with result 'core-dump'.

无法添加本地host

Describe the bug
我从本地host设置了域名对应的ip,但是无法解析域名,直接失败了

Screenshots
image

no errors reported when config file is not correct

example wrong config file listed below, note that there is a "," instead of a ";" between the server key and cert.
{
"log":{
"level":"info",
"output":"/var/log/realm-tls.log"
},
"network":{
"zero_copy":true
},
"endpoints":[
{
"listen":"0.0.0.0:443",
"listen_transport": "tls;cert=cert.cer,key=cert.key",
"remote":"127.0.0.1:444"
}
]
}

the correct config file should be:

{
"log":{
"level":"info",
"output":"/var/log/realm-tls.log"
},
"network":{
"zero_copy":true
},
"endpoints":[
{
"listen":"0.0.0.0:443",
"listen_transport": "tls;cert=cert.cer;key=cert.key",
"remote":"127.0.0.1:444"
}
]
}

benchmark: realm vs gost

NO WARRANTY

Data are roughly collected. You should never rely on these results for any serious purpose.

Tool

Realm:

realm -v
Realm 2.0.0 [udp][zero-copy][trust-dns][proxy-protocol][multi-thread]

Gost:

gost -V
gost 3.0.0-beta.2 (go1.18.1 linux/amd64)

Environment

Run these tools in a container:

docker run -it --cpus=0.5 --name=relay bench /bin/bash

We simply limit CPU usage to make sure network would not become the bottleneck during a benchmark. And there is no extra restriction on memory usage.

Command

A(host) => B(docker) => C(docker) => D(host)

A:

iperf3 -c 172.17.0.2 -p 8080 -t 60 -P [1,10,30,50,100]

D:

iperf3 -s -p 5201

TCP

Realm:

realm -l 0.0.0.0:8080 -r 172.17.0.1:5201 -z

Gost:

gost -L tcp://:8080/172.17.0.1:5201 2>/dev/null

WS

Realm:

realm -l 0.0.0.0:8080 -r 172.17.0.3:8080 -b 'ws;host=abc;path=/'
realm -l 0.0.0.0:8080 -r 172.17.0.1:5201 -a 'ws;host=abc;path=/'

Gost:

gost -L tcp://:8080 -F relay+ws://172.17.0.3:8080 2>/dev/null
gost -L relay+ws://:8080/172.17.0.1:5201 2>/dev/null

WSS

Realm:

realm -l 0.0.0.0:8080 -r 172.17.0.3:8080 -b 'ws;host=abc;path=/;tls;insecure;sni=abc'
realm -l 0.0.0.0:8080 -r 172.17.0.1:5201 -a 'ws;host=abc;path=/;tls;servername=abc'

Gost:

gost -L tcp://:8080 -F relay+wss://172.17.0.3:8080 2>/dev/null
gost -L relay+wss://:8080/172.17.0.1:5201 2>/dev/null

Result

TCP:

TCP Bandwidth
TCP Memory

WS:

WS Bandwidth
WS Memory

WSS:

WSS Bandwidth
WSS Memory

多ip 多端口 转发配置失败

想实现 本地443 转发远程 1.1.1.1:443
本地 1443 转发 远程2.2.2.2:1443

按博客上给的 示例改动了下 这2个转发 只有运行一个有效。
{
"listening_addresses": ["0.0.0.0"],
"listening_ports": ["443","1443"],
"remote_addresses": ["1.1.1.1","2.2.2.2"],
"remote_ports": ["443","1443"]
}

能给个实现上面目的的有效配置吗?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.