Skip to content

Commit 73dbe47

Browse files
authored
Merge pull request #62 from Kumassy/feature/fix-api-service
fix api service is not working
2 parents 3608966 + 0d0aeca commit 73dbe47

File tree

7 files changed

+50
-48
lines changed

7 files changed

+50
-48
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -54,33 +54,34 @@ We also offer GUI. visit [ownserver-client-gui](https://github.com/Kumassy/ownse
5454

5555
```sh
5656
% ownserver -h
57-
ownserver 0.5.1
58-
59-
USAGE:
60-
ownserver [OPTIONS]
61-
62-
FLAGS:
63-
-h, --help Prints help information
64-
-V, --version Prints version information
65-
66-
OPTIONS:
67-
--control-port <control-port> Advanced settings [default: 5000]
68-
--local-port <local-port> Port of your local game server listens e.g.) 25565 for Minecraft [default:
69-
3000]
70-
--payload <payload> tcp or udp [default: tcp]
71-
--token-server <token-server> Advanced settings [default: https://auth.ownserver.kumassy.com/v1/request_token]
57+
Expose your local game server to the Internet
58+
59+
Usage: ownserver [OPTIONS] --endpoint <ENDPOINT>
60+
61+
Options:
62+
--endpoint <ENDPOINT>
63+
Port and protocol of your local game server e.g.) `25565/tcp` for Minecraft
64+
--api-port <API_PORT>
65+
Advanced settings. You can inspect client's internal state at localhost:<api_port>.
66+
--control-port <CONTROL_PORT>
67+
Advanced settings [default: 5000]
68+
--token-server <TOKEN_SERVER>
69+
Advanced settings [default: https://auth.ownserver.kumassy.com/v2/request_token]
70+
--periodic-ping-interval <PERIODIC_PING_INTERVAL>
71+
[default: 15]
72+
-h, --help
73+
Print help
74+
-V, --version
7275
7376
# listen on local port
7477
% nc -kl 3000
7578
76-
% ownserver --payload tcp --local-port 3000
77-
Connecting to auth server: https://auth.ownserver.kumassy.com/v1/request_token
78-
Your proxy server: shard-7924.ownserver.kumassy.com
79-
Connecting to proxy server: shard-7924.ownserver.kumassy.com:5000
80-
Your Client ID: client_755d0b36-f863-41e1-b5ff-c6c89fdb92a5
81-
+---------------------------------------------------------------------------------------------------+
82-
| Your server tcp://localhost:3000 is now available at tcp://shard-7924.ownserver.kumassy.com:17974 |
83-
+---------------------------------------------------------------------------------------------------+
79+
% ownserver --endpoint 3010/tcp
80+
Your Client ID: client_17638595-be9d-41b9-89bf-c678c1e98d10
81+
Endpoint Info:
82+
+------------------------------------------------------------------------+
83+
| tcp://localhost:3010 <--> tcp://shard-2509.ownserver.kumassy.com:15335 |
84+
+------------------------------------------------------------------------+
8485
8586
# you can send any TCP packet to local port!
8687
% nc shard-7924.ownserver.kumassy.com 17974
@@ -100,7 +101,7 @@ via cargo
100101
java -Xmx1024M -Xms1024M -jar server.jar nogui
101102
102103
# run ownserver client
103-
ownserver -- --payload tcp --local-port 25565
104+
ownserver -- --endpoint 25565/tcp
104105
```
105106
106107
share your public URL!
@@ -110,12 +111,12 @@ You can query endpoints and streams info using the client API.
110111
You need to specify local port to use the API:
111112
112113
```
113-
% ownserver --payload tcp --local-port 3000 --api-port 9000
114+
% ownserver --endpoint 25565/tcp --api-port 9000
114115
115116
% curl -s localhost:9000/endpoints
116-
[{"id":"client_be38a93b-b7a9-46da-9d9d-51df95cad828","local_port":3000,"remote_addr":"shard-5346.ownserver.kumassy.com:13574"}]
117+
[[{"id":"02291214-8647-4d08-ace3-032ac255bb14","protocol":"TCP","local_port":3010,"remote_port":19083}]]
117118
% curl -s localhost:9000/streams
118-
[{"id":"stream_24a3b5bb-336d-4b4e-baf3-7ef61bc1b78c"}]
119+
[{"stream_id":"5768354e-97c9-4c6a-8cd2-8163a1f3621c","remote_info":{"remote_peer_addr":"x.x.x.x:13367"}}]
119120
```
120121
121122
## How it works

ownserver/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ownserver"
3-
version = "0.7.0"
3+
version = "0.7.1"
44
authors = ["Kumassy <kumassyii@gmail.com>"]
55
edition = "2021"
66
license = "MIT"
@@ -14,7 +14,7 @@ keywords = ["network", "networking", "game", "minecraft"]
1414
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1515

1616
[dependencies]
17-
ownserver_lib = { version = "0.7.0", path = "../ownserver_lib" }
17+
ownserver_lib = { version = "0.7.1", path = "../ownserver_lib" }
1818
tokio = { version = "1", features = ["full"] }
1919
tokio-util = "0.7"
2020
tokio-tungstenite = { version = '0.22', features = ["rustls"] }

ownserver/src/main.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,20 @@ async fn main() -> Result<()> {
7878

7979
let store_ = store.clone();
8080

81+
if let Some(api_port) = cli.api_port {
82+
info!("client side api is available at localhost:{}", api_port);
83+
tokio::spawn(async move {
84+
api::spawn_api(store_, api_port).await;
85+
});
86+
}
87+
8188
info!("start client main loop");
82-
run_client(&config, store_, cancellation_token,
89+
run_client(&config, store, cancellation_token,
8390
RequestType::NewClient {
8491
endpoint_claims: cli.endpoint
8592
}
8693
).await?;
8794

88-
if let Some(api_port) = cli.api_port {
89-
info!("client side api is available at localhost:{}", api_port);
90-
tokio::spawn(async move {
91-
api::spawn_api(store, api_port).await;
92-
});
93-
}
9495

9596
Ok(())
9697
}

ownserver_lib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ownserver_lib"
3-
version = "0.7.0"
3+
version = "0.7.1"
44
authors = ["Kumassy <kumassyii@gmail.com>"]
55
edition = "2021"
66
license = "MIT"

ownserver_server/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
[package]
22
name = "ownserver_server"
3-
version = "0.7.0"
3+
version = "0.7.1"
44
authors = ["Kumassy <kumassyii@gmail.com>"]
55
edition = "2021"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88

99
[dependencies]
10-
ownserver_lib = { version = "0.7.0", path = "../ownserver_lib" }
11-
ownserver = { version = "0.7.0", path = "../ownserver" }
10+
ownserver_lib = { version = "0.7.1", path = "../ownserver_lib" }
11+
ownserver = { version = "0.7.1", path = "../ownserver" }
1212
tokio-tungstenite = { version = '0.26', features = ["rustls"] }
1313
tokio = { version = "1.44", features = ["full", "tracing"] }
1414
tokio-util = "0.7"

ownserver_test/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
[package]
22
name = "ownserver_test"
3-
version = "0.7.0"
3+
version = "0.7.1"
44
authors = ["Kumassy <kumassyii@gmail.com>"]
55
edition = "2021"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88

99
[dependencies]
10-
ownserver_lib = { version = "0.7.0", path = "../ownserver_lib" }
11-
ownserver = { version = "0.7.0", path = "../ownserver" }
12-
ownserver_server = { version = "0.7.0", path = "../ownserver_server" }
10+
ownserver_lib = { version = "0.7.1", path = "../ownserver_lib" }
11+
ownserver = { version = "0.7.1", path = "../ownserver" }
12+
ownserver_server = { version = "0.7.1", path = "../ownserver_server" }
1313
tokio-tungstenite = { version = '0.26', features = ["rustls"] }
1414
tokio = { version = "1", features = ["full"] }
1515
tokio-util = "0.7"

0 commit comments

Comments
 (0)