Compare commits
No commits in common. "asyncversion" and "v1.0" have entirely different histories.
asyncversi
...
v1.0
|
|
@ -1,4 +1,4 @@
|
|||
target/
|
||||
/target
|
||||
.vscode
|
||||
main
|
||||
main.exe
|
||||
|
|
@ -8,4 +8,3 @@ restarts.log
|
|||
nohup.out
|
||||
server.log
|
||||
control_panel.log
|
||||
onefetch.out
|
||||
41
README.md
41
README.md
|
|
@ -1,6 +1,6 @@
|
|||
# VelNet Server
|
||||
# VelNetServerRust
|
||||
|
||||
This basic, single-file relay server is designed to be used for network games, and is similar to Photon Realtime in design. It is written in Rust, with a single-threaded, non-blocking design and does not rely on any network frameworks (pure TCP/UDP). A Unity/C# client implementation can be found in our [VelNetUnity](https://github.com/velaboratory/VelNetUnity) repository.
|
||||
This basic, single-file relay server is designed to be used for network games, and is similar to Photon Realtime in design. It is written in Rust, with a single-threaded, non-blocking design and does not rely on any network frameworks (pure TCP/UDP). A Unity/C# client implementation can be found in our VelNetUnity repository.
|
||||
|
||||
Like Photon, there is no built-in persistence of rooms or data. Rooms are created when the first client joins and destroyed when the last client leaves.
|
||||
|
||||
|
|
@ -12,45 +12,12 @@ The server supports both TCP and UDP transports.
|
|||
|
||||
## Running
|
||||
|
||||
### Option 1: Pull from Docker Hub
|
||||
|
||||
```sh
|
||||
docker run -p 5000:5000 -p 5000:5000/udp velaboratory/velnet
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```sh
|
||||
docker run -p 5050:5000 -p 5050:5000/udp --name velnet velaboratory/velnet
|
||||
```
|
||||
To run on a different port and change the name of the container.
|
||||
|
||||
### Option 2: Use docker-compose
|
||||
|
||||
Runs both the control panel and the server.
|
||||
|
||||
```sh
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
to run, and
|
||||
|
||||
```sh
|
||||
docker compose stop
|
||||
```
|
||||
to stop.
|
||||
|
||||
This builds the images from the local data in the folder, and doesn't pull anything from Docker Hub.
|
||||
|
||||
### Option 3: Run Rust natively
|
||||
|
||||
1. Get a linoox server (also runs fine on Windows & OSX, but the instructions below are for Linux)
|
||||
1. Get a linoox server (also runs fine on windows & osx, but the instructions below are for linux)
|
||||
2. Clone this repo
|
||||
3. Edit `config.json` to an open port on your firewall
|
||||
3. Edit config.json to an open port on your firewall
|
||||
4. Modify the `user` field in `control-panel/config.json` to be your username.
|
||||
5. Install rust through using rustup: https://rustup.rs/
|
||||
6. Install: `sudo ./install.sh`
|
||||
7. Run server: `sudo systemctl start velnet`
|
||||
8. Run control panel: `sudo systemctl start velnet-control-panel`
|
||||
9. Install tuptime: `cargo install tuptime`
|
||||
9. Install onefetch: `cargo install onefetch`
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
"port": 5000,
|
||||
"tcp_timeout": 30,
|
||||
"log_file": "logs/server.log"
|
||||
"log_file": "server.log"
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
/target
|
||||
.vscode
|
||||
main
|
||||
main.exe
|
||||
main.pdb
|
||||
.idea/
|
||||
onefetch.out
|
||||
|
|
@ -6,7 +6,7 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
actix-web = "4.1.0"
|
||||
actix-web = "4"
|
||||
handlebars = { version = "4.2.1", features = ["dir_source"] }
|
||||
serde_json = "1.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
|
|
|||
|
|
@ -1,41 +0,0 @@
|
|||
FROM rust:1.64 as build
|
||||
|
||||
# 1. Create a new empty shell project
|
||||
RUN USER=root cargo new --bin velnet_control_panel
|
||||
WORKDIR /velnet_control_panel
|
||||
|
||||
# 2. Copy our manifests
|
||||
COPY ./Cargo.lock ./Cargo.lock
|
||||
COPY ./Cargo.toml ./Cargo.toml
|
||||
|
||||
# 3. Build only the dependencies to cache them
|
||||
RUN cargo build --release && rm src/*.rs
|
||||
|
||||
# 4. Now that the dependency is built, copy your source code
|
||||
COPY ./src ./src
|
||||
|
||||
# 5. Build for release.
|
||||
RUN rm ./target/release/deps/velnet_control_panel*
|
||||
RUN cargo build --release
|
||||
|
||||
# our final base
|
||||
FROM rust:1.64-slim
|
||||
WORKDIR /velnet_control_panel
|
||||
|
||||
# RUN apt-get update && apt-get install -y extra-runtime-dependencies && rm -rf /var/lib/apt/lists/*
|
||||
RUN apt update && apt install -y tuptime
|
||||
|
||||
# copy the build artifact from the build stage
|
||||
COPY --from=build /velnet_control_panel/target/release/velnet_control_panel .
|
||||
|
||||
# Copy the config files and helper scripts
|
||||
COPY static static
|
||||
COPY config.json .
|
||||
COPY onefetch_file.sh .
|
||||
COPY git_pull.sh .
|
||||
COPY compile_server.sh .
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
# run
|
||||
CMD ["./velnet_control_panel"]
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"port": 8080,
|
||||
"user": "ntsfranz",
|
||||
"server_log_file": "../logs/server.log",
|
||||
"server_log_file": "../server.log",
|
||||
"control_panel_log_file": "control_panel.log",
|
||||
"server_dir": "../",
|
||||
"handlebars_dev_mode": true
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
docker stop velnet_control_panel
|
||||
docker build -t velaboratory/velnet_control_panel .
|
||||
docker rm velnet_control_panel
|
||||
docker run -d -p 8080:8080 --name velnet_control_panel velaboratory/velnet_control_panel
|
||||
|
|
@ -49,24 +49,24 @@ async fn index(hb: web::Data<Handlebars<'_>>) -> HttpResponse {
|
|||
|
||||
// let restarts_log = lines_from_file(config.restarts_log_file);
|
||||
|
||||
let uptime = Command::new("tuptime")
|
||||
let uptime = Command::new("uptime")
|
||||
.output()
|
||||
.expect("failed to execute process");
|
||||
|
||||
// let _onefetch = Command::new("sh")
|
||||
// .arg("onefetch_file.sh")
|
||||
// .arg(config.user)
|
||||
// .output()
|
||||
// .expect("failed");
|
||||
let _onefetch = Command::new("sh")
|
||||
.arg("onefetch_file.sh")
|
||||
.arg(config.user)
|
||||
.output()
|
||||
.expect("failed");
|
||||
|
||||
// let onefetch = fs::read_to_string("onefetch.out").unwrap();
|
||||
let onefetch = fs::read_to_string("onefetch.out").unwrap();
|
||||
|
||||
let data = json!({
|
||||
"log_output": &log_file[(cmp::max((log_file.len() as i64) - 1000, 0) as usize)..],
|
||||
// "restarts_output": &restarts_log[(cmp::max((restarts_log.len() as i64) - 1000, 0) as usize)..],
|
||||
"uptime": format!("{}", String::from_utf8_lossy(&uptime.stdout)),
|
||||
//"onefetch": format!("{}", String::from_utf8_lossy(&onefetch.stdout))
|
||||
"onefetch": ""
|
||||
"onefetch": onefetch.trim_end()
|
||||
});
|
||||
let body = hb.render("index", &data).unwrap();
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
<style>
|
||||
.bottom-scroller {
|
||||
max-height: 40em;
|
||||
height: 40em;
|
||||
overflow: auto;
|
||||
display: flex;
|
||||
flex-direction: column-reverse;
|
||||
|
|
@ -45,16 +45,17 @@
|
|||
|
||||
</section>
|
||||
|
||||
{{!-- <section>
|
||||
<section>
|
||||
<div class="container">
|
||||
<div class="block">
|
||||
<button class="button" id="restart-button">Restart Server</button>
|
||||
<button class="button" id="pull-button">Git Pull</button>
|
||||
<button class="button" id="compile-button">Compile</button>
|
||||
</div>
|
||||
<pre style="font-size: 0.8em;">{{uptime}}</pre>
|
||||
<div class="block">Uptime: {{uptime}}</div>
|
||||
<pre style="font-size: 0.8em;">{{onefetch}}</pre>
|
||||
</div>
|
||||
</section> --}}
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
version: "3.9"
|
||||
services:
|
||||
control-panel:
|
||||
build: control-panel
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
- logs-volume:/logs
|
||||
server:
|
||||
build: server
|
||||
ports:
|
||||
- "5000:5000/tcp"
|
||||
- "5000:5000/udp"
|
||||
volumes:
|
||||
- logs-volume:/logs
|
||||
|
||||
|
||||
volumes:
|
||||
logs-volume:
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
FROM rust:1.64 as build
|
||||
|
||||
# 1. Create a new empty shell project
|
||||
RUN USER=root cargo new --bin velnet_server
|
||||
WORKDIR /velnet_server
|
||||
|
||||
# 2. Copy our manifests
|
||||
COPY ./Cargo.lock ./Cargo.lock
|
||||
COPY ./Cargo.toml ./Cargo.toml
|
||||
|
||||
# 3. Build only the dependencies to cache them
|
||||
RUN cargo build --release && rm src/*.rs
|
||||
|
||||
# 4. Now that the dependency is built, copy your source code
|
||||
COPY ./src ./src
|
||||
|
||||
# 5. Build for release.
|
||||
RUN rm ./target/release/deps/velnet_server*
|
||||
RUN cargo build --release
|
||||
|
||||
# our final base
|
||||
FROM debian:buster-slim
|
||||
|
||||
# copy the build artifact from the build stage
|
||||
COPY --from=build /velnet_server/target/release/velnet_server .
|
||||
COPY config.json .
|
||||
|
||||
EXPOSE 5000/tcp
|
||||
EXPOSE 5000/udp
|
||||
|
||||
# run
|
||||
CMD ["./velnet_server"]
|
||||
Loading…
Reference in New Issue