Skip to content

Commit f893421

Browse files
authored
Merge pull request #44 from zenuo/rust-server
Rust server
2 parents c379833 + 871874c commit f893421

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+442
-2181
lines changed

README.md

+11-16
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
> 强烈感谢[webbillion](https://github.com/webbillion)同学的域名服务🤗🎉
66
77
- [gogo.webbillion.cn](https://gogo.webbillion.cn/)
8+
- [176.122.157.231:5002](https://176.122.157.231:5002)
89

910
## 如何使用
1011

@@ -14,11 +15,11 @@
1415

1516
首页截图:
1617

17-
![6c44f17c7e035221816e7530.png](image/6c44f17c7e035221816e7530.png)
18+
![home.png](image/home.png)
1819

1920
搜索页面截图:
2021

21-
![e5c1b9df30645ffb8059ca72.png](image/e5c1b9df30645ffb8059ca72.png)
22+
![search.png](image/search.png)
2223

2324
### 2 命令行
2425

@@ -30,20 +31,16 @@ $ gogo-cli github 1
3031

3132
截图如下:
3233

33-
![639ad4d3863e52f90a16cbe5.png](image/639ad4d3863e52f90a16cbe5.png)
34+
![cli.png](image/cli.png)
3435

3536
### 3 API
3637

3738
#### 搜索
3839

3940
```bash
40-
$ curl -X GET -k "https://176.122.157.231:5000/api/search?q=github&p=1"
41+
$ curl -X GET -k "http://localhost:4998/api/search?q=github&p=1"
4142
{
42-
"key": "github",
43-
"page": 1,
44-
"amount": 223000000,
45-
"elapsed": 0.43,
46-
"entries": [
43+
"result": [
4744
{
4845
"name": "The world's leading software development platform · GitHub",
4946
"url": "https://github.com/",
@@ -57,10 +54,9 @@ $ curl -X GET -k "https://176.122.157.231:5000/api/search?q=github&p=1"
5754
#### 关键词提示
5855

5956
```bash
60-
$ curl -X GET -k "https://176.122.157.231:5000/api/lint?q=github"
57+
$ curl -X GET -k "http://localhost:4998/api/lint?q=github"
6158
{
62-
"key": "github",
63-
"lints": [
59+
"result": [
6460
"github",
6561
"github<b> desktop</b>",
6662
"github<b> stock</b>",
@@ -86,7 +82,7 @@ $ docker pull zenuo/gogo
8682
# 创建容器
8783
$ docker create -p 4999:4999 --name gogo zenuo/gogo
8884
# 复制配置文件到容器(可选)
89-
$ docker cp application.yml gogo:/opt/gogo/application.yml
85+
$ docker cp config.json gogo:/opt/gogo/application.json
9086
# 运行镜像
9187
$ docker start gogo
9288
# 查看日志(可选)
@@ -98,7 +94,6 @@ $ docker logs -f gogo
9894
```
9995
$ git clone https://github.com/zenuo/gogo.git
10096
$ cd gogo/gogo-server
101-
$ mvn -DskipTests=true clean package
102-
$ mv target/gogo.jar .
103-
$ sh ./gogo-server.sh
97+
$ cargo build -rv
98+
$ ./target/release/gogo-server config
10499
```

gogo-cli/main.go

+3-7
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import (
1414
)
1515

1616
const executableName string = "gogo-cli"
17-
const version string = "0.21"
17+
const version string = "2.0.0"
1818
const host string = "176.122.157.231"
19-
const port int = 5000
19+
const port int = 5002
2020

2121
// Entry 条目
2222
type Entry struct {
@@ -27,11 +27,7 @@ type Entry struct {
2727

2828
// SearchResponse 搜索响应
2929
type SearchResponse struct {
30-
Key string `json:"key"`
31-
Page uint64 `json:"page"`
32-
Amount uint64 `json:"amount"`
33-
Elapsed float64 `json:"elapsed"`
34-
Entries []Entry `json:"entries"`
30+
Entries []Entry `json:"result"`
3531
Error string `json:"error"`
3632
}
3733

gogo-server/.cargo/config.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[target.x86_64-unknown-linux-musl]
2+
rustflags = ["-Ctarget-feature=-crt-static"]
3+

gogo-server/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/target
2+
.vscode
3+
Cargo.lock
4+
.DS_Store

gogo-server/Cargo.toml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[package]
2+
name = "gogo-server"
3+
version = "2.0.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
9+
pretty_env_logger = "0.4"
10+
log = "0.4"
11+
html5ever = "0.26.0"
12+
tokio = { version = "1", features = ["full"] }
13+
warp = "0.3"
14+
serde = { version = "1.0", features = ["derive"] }
15+
serde_json = "1.0"
16+
reqwest = { version = "0.11", features = ["socks", "native-tls"] }
17+
url = "2.3.1"
18+
kuchiki = "0.8.1"
19+
once_cell = "1.16.0"
20+
clap = { version = "4.0", features = ["derive"] }
21+
22+
[profile.dev]
23+
opt-level = 0
24+
25+
[profile.release]
26+
opt-level = 3
27+

gogo-server/Dockerfile

-9
This file was deleted.

gogo-server/application.yml

-4
This file was deleted.

gogo-server/config.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"listen_address": "127.0.0.1:4998",
3+
"google_base_url": "https://google.com",
4+
"static_path": "gogo-web/",
5+
"http_client_pool_max_idle_per_host": 20,
6+
"http_client_connect_timeout_millis": 60000,
7+
"danger_accept_invalid_certs": false,
8+
"user_agents": [
9+
"Lynx/2.8.5rel.2 libwww-FM",
10+
"Lynx/2.7.5rel.1 libwww-FM",
11+
"Lynx/1.9.5rel.9 libwww-FM",
12+
"Lynx/1.8.1rel.3 libwww-FM"
13+
],
14+
"headers": {
15+
"accept-language": "en-US,en;q=0.9",
16+
"cache-control": "no-cache"
17+
},
18+
"proxy": "socks5://localhost:9050"
19+
}

gogo-server/pom.xml

-135
This file was deleted.

0 commit comments

Comments
 (0)