added scripts

This commit is contained in:
asxalex 2024-02-19 09:13:43 +08:00
parent 42d9c3125f
commit 39643f6466
5 changed files with 38 additions and 4 deletions

View File

@ -19,6 +19,11 @@ rsa = "0.9.6"
serde = { version = "1.0.196", features = ["derive"] }
serde_json = "1.0.113"
serde_repr = "0.1.18"
sqlx = { version = "0.7.3", features = [
"sqlx-sqlite",
"sqlite",
"runtime-tokio",
] }
structopt = "0.3.26"
tokio = { version = "1.36.0", features = ["full"] }
tracing = "0.1.40"

View File

@ -1,4 +1,5 @@
# sdlan rust版本
rust版本的sdlan。
* [protocol](./docs/protocol.md)
* [protocol](./docs/protocol.md)
* [design](./docs/design.md)

17
docs/design.md Normal file
View File

@ -0,0 +1,17 @@
# sdlan-sn设计
服务端为单体应用,多个服务端可以同时启动,后面的服务端启动时,可以指定`--fedration x.x.x.x:7655,y.y.y.y:7656`命令行参数来指定其他的服务端,服务端将其他服务端的信息保存在`fedration`这个network里面。
比如有如下的结构:
```mermaid
graph TD
A[服务端1]
B[服务端2]
C[节点1]
D[节点2]
A .- B
A --- C
B --- D
```
服务端1和服务端2通过udp连接现在分别有个节点连接到对应的服务端

11
scripts/mysql.md Normal file
View File

@ -0,0 +1,11 @@
# mysql操作记录
```shell
# 添加用户
CREATE USER 'username'@'host' IDENTIFIED BY 'password';
# 授权
GRANT ALL PRIVILEGES ON db.* TO 'username'@'host';
# 刷新权限
FLUSH ALL PRIVILEGES;
```

View File

@ -36,7 +36,7 @@ pub struct SuperNode {
pub daemon: bool,
// 本地监听的udp端口号
pub local_port: i16,
pub local_port: u16,
// 该SuperNode包含的所有的网络
// 在云端创建或者删除网络的时候需要通知sn修改这个网络信息
@ -61,7 +61,7 @@ pub struct SuperNode {
}
impl SuperNode {
pub fn new(sock: UdpSocket) -> Self {
pub fn new(sock: UdpSocket, localport: u16) -> Self {
let now = SystemTime::now();
println!("now: {:?}", now);
let start_time = now
@ -80,7 +80,7 @@ impl SuperNode {
Self {
start_time,
daemon: false,
local_port: 7655,
local_port: localport,
networks: MyDashMap::new(),
fedration: Network::new("*fedration", gen_uuid(), true, 0, 0),
pending: Network::new("*pending", gen_uuid(), false, 0, 0),