Spaces:
Paused
Paused
xukc
commited on
Commit
Β·
8122175
1
Parent(s):
9ab4bcb
[opt]build opt
Browse files- .vscode/launch.json +1 -1
- .vscode/tasks.json +5 -7
- Dockerfile +2 -2
- hv_utils.cpp β src/hv_utils.cpp +1 -1
- main.cpp β src/main.cpp +2 -2
- tcp_client.cpp β src/tcp_client.cpp +2 -2
- tcp_inbound.cpp β src/tcp_inbound.cpp +4 -5
.vscode/launch.json
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
"name": "Debug",
|
6 |
"type": "cppdbg",
|
7 |
"request": "launch",
|
8 |
-
"program": "${workspaceFolder}/
|
9 |
"args": [],
|
10 |
"stopAtEntry": false,
|
11 |
"cwd": "${workspaceFolder}",
|
|
|
5 |
"name": "Debug",
|
6 |
"type": "cppdbg",
|
7 |
"request": "launch",
|
8 |
+
"program": "${workspaceFolder}/proxyServerTcp",
|
9 |
"args": [],
|
10 |
"stopAtEntry": false,
|
11 |
"cwd": "${workspaceFolder}",
|
.vscode/tasks.json
CHANGED
@@ -9,15 +9,13 @@
|
|
9 |
"-std=c++14",
|
10 |
"-g",
|
11 |
"-o",
|
12 |
-
"
|
13 |
"-I",
|
14 |
"include",
|
15 |
-
"-I",
|
16 |
-
"include/bolt",
|
17 |
-
"
|
18 |
-
"
|
19 |
-
"tcp_client.cpp",
|
20 |
-
"main.cpp",
|
21 |
"-lhv",
|
22 |
"-lspdlog"
|
23 |
|
|
|
9 |
"-std=c++14",
|
10 |
"-g",
|
11 |
"-o",
|
12 |
+
"proxyServerTcp",
|
13 |
"-I",
|
14 |
"include",
|
15 |
+
// "-I",
|
16 |
+
// "include/bolt",
|
17 |
+
// "*.cpp",
|
18 |
+
"src/*.cpp",
|
|
|
|
|
19 |
"-lhv",
|
20 |
"-lspdlog"
|
21 |
|
Dockerfile
CHANGED
@@ -50,7 +50,7 @@ WORKDIR /app
|
|
50 |
COPY . .
|
51 |
|
52 |
# Compile the C++ program
|
53 |
-
RUN g++ -std=c++14 -g -o
|
54 |
|
55 |
RUN apt-get install -y tzdata
|
56 |
|
@@ -61,4 +61,4 @@ RUN dpkg-reconfigure --frontend noninteractive tzdata
|
|
61 |
|
62 |
EXPOSE 8080
|
63 |
# Run my_program when the container launches
|
64 |
-
CMD ["./
|
|
|
50 |
COPY . .
|
51 |
|
52 |
# Compile the C++ program
|
53 |
+
RUN g++ -std=c++14 -g -o proxyServerTcp src/*.cpp -I include -lhv -lspdlog
|
54 |
|
55 |
RUN apt-get install -y tzdata
|
56 |
|
|
|
61 |
|
62 |
EXPOSE 8080
|
63 |
# Run my_program when the container launches
|
64 |
+
CMD ["./proxyServerTcp"]
|
hv_utils.cpp β src/hv_utils.cpp
RENAMED
@@ -1,4 +1,4 @@
|
|
1 |
-
#include "
|
2 |
|
3 |
int thread_num = 4;
|
4 |
hloop_t** worker_loops = NULL;
|
|
|
1 |
+
#include "hv_utils.h"
|
2 |
|
3 |
int thread_num = 4;
|
4 |
hloop_t** worker_loops = NULL;
|
main.cpp β src/main.cpp
RENAMED
@@ -129,8 +129,8 @@
|
|
129 |
|
130 |
#include "hv/hloop.h"
|
131 |
#include "hv/hthread.h"
|
132 |
-
#include "
|
133 |
-
#include "
|
134 |
|
135 |
#include "spdlog/spdlog.h"
|
136 |
#include "spdlog/async.h"
|
|
|
129 |
|
130 |
#include "hv/hloop.h"
|
131 |
#include "hv/hthread.h"
|
132 |
+
#include "hv_utils.h"
|
133 |
+
#include "tcp_inbound.h"
|
134 |
|
135 |
#include "spdlog/spdlog.h"
|
136 |
#include "spdlog/async.h"
|
tcp_client.cpp β src/tcp_client.cpp
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
-
#include "
|
2 |
#include "bolt/datagram.h"
|
3 |
-
#include "
|
4 |
#include "spdlog/spdlog.h"
|
5 |
#include <string>
|
6 |
#include <time.h>
|
|
|
1 |
+
#include "tcp_client.h"
|
2 |
#include "bolt/datagram.h"
|
3 |
+
#include "tcp_client_map.h"
|
4 |
#include "spdlog/spdlog.h"
|
5 |
#include <string>
|
6 |
#include <time.h>
|
tcp_inbound.cpp β src/tcp_inbound.cpp
RENAMED
@@ -1,9 +1,8 @@
|
|
1 |
-
#include "
|
2 |
-
#include "
|
3 |
-
#include "
|
4 |
#include "hv/hsocket.h"
|
5 |
#include "hv/hthread.h"
|
6 |
-
#include "hv/TcpClient.h"
|
7 |
#include "spdlog/spdlog.h"
|
8 |
#include <string>
|
9 |
|
@@ -42,7 +41,7 @@ void tcp_on_accept(hio_t* io, hevent_t* ev) {
|
|
42 |
SOCKADDR_STR(hio_localaddr(io), localaddrstr),
|
43 |
SOCKADDR_STR(hio_peeraddr(io), peeraddrstr));
|
44 |
|
45 |
-
ConnMap<hio_t*, TcpClientBolt>::getInstance().add(io, std::
|
46 |
|
47 |
hio_setcb_close(io, tcp_on_close);
|
48 |
hio_setcb_read(io, tcp_on_recv);
|
|
|
1 |
+
#include "tcp_inbound.h"
|
2 |
+
#include "conn_map.h"
|
3 |
+
#include "tcp_client.h"
|
4 |
#include "hv/hsocket.h"
|
5 |
#include "hv/hthread.h"
|
|
|
6 |
#include "spdlog/spdlog.h"
|
7 |
#include <string>
|
8 |
|
|
|
41 |
SOCKADDR_STR(hio_localaddr(io), localaddrstr),
|
42 |
SOCKADDR_STR(hio_peeraddr(io), peeraddrstr));
|
43 |
|
44 |
+
ConnMap<hio_t*, TcpClientBolt>::getInstance().add(io, std::make_unique<TcpClientBolt>(io));
|
45 |
|
46 |
hio_setcb_close(io, tcp_on_close);
|
47 |
hio_setcb_read(io, tcp_on_recv);
|