本地服务器

From DDraceNetwork
Revision as of 02:20, 28 July 2023 by Darkh (talk | contribs)

本地服务器是玩家在本地网络(比如家庭wifi)中建立的服务器,建立服务器的玩家拥有对这个服务器的完全控制权。

使用本地服务器的原因有很多。它能够让你做到:

  • 和朋友一起游玩时不受别人打扰
  • 游玩官方服务器中没有的地图
  • 用管理员指令和工具对地图进行测试
  • 以及更多!

然而,建立本地服务器仍然有许多缺点。你需要一些特殊的方法来让你的朋友加入你的服务器,并且相比起官方服务器,其他玩家在你建立的本地服务器中会遭受更多网络的影响。注意本地服务器只会在本地保存过图记录,这意味着你在本地服务器中完成地图并不会将记录同步到官方服务器。


建立和加入本地服务器

在新版DDNet客户端中,建立本地服务器非常简单。

  1. 找到游戏的开始菜单
  2. 点击“运行服务器”
    • 一个黑底白字的命令行窗口会弹出(这可能需要一小段时间)。从这个窗口中复制rcon的密码(也可以在游戏路径的autoexecserver.cfg文件中查看并设置)。
  3. 打开游戏客户端的浏览服务器界面,在上方选择局域网,刷新后即可加入。
  4. 进入游戏后,按f2打开服务器控制台rcon,然后输入密码来获得管理员指令的使用权限。

然而,这样建立的服务器只能够让处在同一局域网中的玩家加入。如果其他玩家不在你身旁,那么想要让他们加入就需要更多步骤。


让本地服务器连接至公网

这一步需要你进行端口映射,其方式取决于你的路由器品牌和类型。

  1. 在路由器上映射或者转发UDP端口8303。
    • 浏览器上一般都有关于端口映射或者转发的教程。内容通常会涉及到登录浏览器接口,不同的家庭各有所异。
    • 确保设置中使用了UDP协议而不是TCP或者两者共用。
    • DDNet默认使用8303端口,如果您对于服务器足够熟悉,也可以通过更改服务器配置文件中的sv_port参数来使用其它端口。
  2. 在 F2 服务器控制台或者服务器配置文件中使用sv_register 1可以让您的服务器出现在游戏服务器界面的互联网列表中。注意这么做会公开您的家庭网络IP,具有一定风险。

一些网络运营商会使用电信级NAT而不提供本地 IPv4 地址的完整级别保护,因此可能无法使用端口转发,以上将服务器联网的方法变得不可用。(关于 IPV6 的方法此处不涉及。)

在Linux上设置服务器

Linux

方法 1 (编译服务器)
[展开 / 折叠]
1.上传服务器
  • sudo apt update && apt upgrade

2. 安装git

  • sudo apt install git

3. 创建目录

  • mkdir DDNet-Server

4. 复制Github上的库

  • git clone --recursive --depth=1 https://github.com/ddnet/ddnet

5. 安装依赖包

  • sudo apt install build-essential cmake git libcurl4-openssl-dev libssl-dev libfreetype6-dev libglew-dev libnotify-dev libogg-dev libopus-dev libopusfile-dev libpnglite-dev libsdl2-dev libsqlite3-dev libwavpack-dev python google-mock

6. 进入 DDNet 文件夹

  • cd ddnet

7. 编译 DDNet

  • mkdir build
  • cd build
  • cmake -DCLIENT=OFF ..
  • make -j$(nproc)

8. 服务器,启动!

  • ./DDNet-Server

9. 转发服务器端口(默认为8303)

10. 使用 IP 通过客户端连接

  • Press F1
  • connect "Server-IP"

10.游玩

更多内容参阅 github

方法 2 (使用预编译的二进制文件)
[展开 / 折叠]
1. 从DDNet 下载页面(download page)上下载二进制文件

2. 解压到文件夹

3. 启动服务器

  • ./DDNet-Server

4. 转发服务器端口(默认为8303)

5. Connect via Client on the IP

  • Press F1
  • connect "Server-IP"

6. Play

More Information about Port forwarding are available at http://portforward.com/


Server Settings and Maps

Everything settings and map-wise can be found in your Teeworlds folder.

  • On Windows, you can find it in AppData/Roaming/Teeworlds.
  • On Linux, you can find it in (insert location here).
  • On Mac, you can find it in (insert location here).


Server Autoexecutables

Server autoexecutables are files containing server settings that are automatically run every time you start your server. For example, this can be helpful if you want to keep a single rcon password to log in with every time.

To create an autoexecutable, navigate to your Teeworlds folder (not your DDNet folder!), and create a file by the name of "autoexec_server.cfg". Make sure it is a .cfg extension file and not a .txt file or anything similar.

To add commands, simply edit the autoexec_server.cfg file and add each command on a new line. Here are examples of commonly used commands:

  • sv_rcon_password <rcon password>
  • sv_password <password to join>
  • sv_name <server name>
  • sv_register 1 (shows the server on the Internet tab)
  • sv_test_cmds 1 (allows the use of cheat commands)


Server Maps

Server maps can be found in Teeworlds/maps. To load a map ingame, use the server command sv_map <mapname>.


另见