Skip to content

Commit c4dd6f4

Browse files
committed
net/proxy:interface move to trunk
1 parent a631019 commit c4dd6f4

40 files changed

+160
-477
lines changed

WORKSPACE

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ boost_deps()
4747

4848
git_repository(
4949
name = "org_iceboy_trunk",
50-
commit = "24fc6171c1512293423d9c2fb093ac2bec86f728",
50+
commit = "ee7aa17695b5b8e65171b23fba3a13a4c6632d64",
5151
remote = "https://github.com/iceboy233/trunk.git",
5252
)

net/proxy/BUILD

+2-17
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,17 @@
11
package(default_visibility = ["//visibility:public"])
22

3-
cc_library(
4-
name = "interface",
5-
hdrs = [
6-
"connector.h",
7-
"datagram.h",
8-
"handler.h",
9-
"stream.h",
10-
],
11-
deps = [
12-
"@com_google_absl//absl/functional:any_invocable",
13-
"@com_google_absl//absl/types:span",
14-
"@org_iceboy_trunk//net:asio",
15-
]
16-
)
17-
183
cc_library(
194
name = "proxy",
205
srcs = ["proxy.cc"],
216
hdrs = ["proxy.h"],
227
deps = [
23-
":interface",
248
":registry",
259
"//net/proxy/system:listener",
2610
"@com_google_absl//absl/container:flat_hash_map",
2711
"@org_boost_boost//:property_tree",
2812
"@org_iceboy_trunk//base:logging",
2913
"@org_iceboy_trunk//net:asio",
14+
"@org_iceboy_trunk//net/interface",
3015
],
3116
)
3217

@@ -35,11 +20,11 @@ cc_library(
3520
srcs = ["registry.cc"],
3621
hdrs = ["registry.h"],
3722
deps = [
38-
":interface",
3923
"@com_google_absl//absl/container:flat_hash_map",
4024
"@com_google_absl//absl/functional:any_invocable",
4125
"@org_boost_boost//:property_tree",
4226
"@org_iceboy_trunk//base:logging",
4327
"@org_iceboy_trunk//net:asio",
28+
"@org_iceboy_trunk//net/interface",
4429
],
4530
)

net/proxy/ares/BUILD

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ cc_library(
1414
deps = [
1515
":error-category",
1616
":socket",
17-
"//net/proxy:interface",
1817
"//third_party/cares",
1918
"//util:int-allocator",
2019
"@com_google_absl//absl/container:flat_hash_map",
@@ -23,6 +22,7 @@ cc_library(
2322
"@org_iceboy_trunk//net:asio",
2423
"@org_iceboy_trunk//net:endpoint",
2524
"@org_iceboy_trunk//net:timer-list",
25+
"@org_iceboy_trunk//net/interface",
2626
],
2727
)
2828

@@ -31,10 +31,10 @@ cc_library(
3131
srcs = ["socket.cc"],
3232
hdrs = ["socket.h"],
3333
deps = [
34-
"//net/proxy:interface",
3534
"//net/proxy/util:write",
3635
"//third_party/cares",
3736
"@org_boost_boost//:smart_ptr",
3837
"@org_iceboy_trunk//net:asio",
38+
"@org_iceboy_trunk//net/interface",
3939
],
4040
)

net/proxy/ares/resolver.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
#include "absl/types/span.h"
1313
#include "net/asio.h"
1414
#include "net/endpoint.h"
15-
#include "net/proxy/ares/socket.h"
16-
#include "net/proxy/connector.h"
1715
#include "net/timer-list.h"
16+
#include "net/interface/connector.h"
17+
#include "net/proxy/ares/socket.h"
1818
#include "util/int-allocator.h"
1919

2020
namespace net {
@@ -64,7 +64,7 @@ class Resolver {
6464
static const ares_socket_functions funcs_;
6565

6666
any_io_executor executor_;
67-
proxy::Connector &connector_;
67+
Connector &connector_;
6868
ares_channel channel_ = nullptr;
6969
steady_timer wait_timer_;
7070
TimerList cache_timer_list_;

net/proxy/ares/socket.cc

+5-16
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,7 @@ int TcpSocket::connect(const sockaddr *addr, ares_socklen_t addr_len) {
100100
}
101101
ares_process_fd(socket->channel_, socket->fd_, socket->fd_);
102102
};
103-
if (address.is_v4()) {
104-
connector_.connect_tcp_v4(
105-
address.to_v4(), port, {}, std::move(callback));
106-
} else {
107-
connector_.connect_tcp_v6(
108-
address.to_v6(), port, {}, std::move(callback));
109-
}
103+
connector_.connect({address, port}, {}, std::move(callback));
110104
SET_ERRNO(EINPROGRESS);
111105
return -1;
112106
}
@@ -198,16 +192,11 @@ int UdpSocket::connect(const sockaddr *addr, ares_socklen_t addr_len) {
198192
SET_ERRNO(EINVAL);
199193
return -1;
200194
}
201-
if (address.is_v4()) {
202-
if (connector_.bind_udp_v4(datagram_)) {
203-
return -1;
204-
}
205-
} else {
206-
if (connector_.bind_udp_v6(datagram_)) {
207-
return -1;
208-
}
195+
udp::endpoint endpoint(address, port);
196+
if (connector_.bind({endpoint.protocol(), 0}, datagram_)) {
197+
return -1;
209198
}
210-
send_endpoint_ = udp::endpoint(address, port);
199+
send_endpoint_ = endpoint;
211200
post(executor_, [socket = boost::intrusive_ptr<UdpSocket>(this)]() {
212201
ares_process_fd(socket->channel_, socket->fd_, socket->fd_);
213202
});

net/proxy/ares/socket.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#include <boost/smart_ptr/intrusive_ref_counter.hpp>
99

1010
#include "net/asio.h"
11-
#include "net/proxy/connector.h"
12-
#include "net/proxy/datagram.h"
13-
#include "net/proxy/stream.h"
11+
#include "net/interface/connector.h"
12+
#include "net/interface/datagram.h"
13+
#include "net/interface/stream.h"
1414

1515
namespace net {
1616
namespace proxy {

net/proxy/connector.h

-52
This file was deleted.

net/proxy/datagram.h

-34
This file was deleted.

net/proxy/handler.h

-23
This file was deleted.

net/proxy/misc/BUILD

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ cc_library(
1818
srcs = ["echo-handler.cc"],
1919
hdrs = ["echo-handler.h"],
2020
deps = [
21-
"//net/proxy:interface",
2221
"//net/proxy/util:write",
2322
"@com_google_absl//absl/container:fixed_array",
23+
"@org_iceboy_trunk//net/interface",
2424
],
2525
)
2626

@@ -29,8 +29,8 @@ cc_library(
2929
srcs = ["null-handler.cc"],
3030
hdrs = ["null-handler.h"],
3131
deps = [
32-
"//net/proxy:interface",
3332
"@com_google_absl//absl/container:fixed_array",
33+
"@org_iceboy_trunk//net/interface",
3434
],
3535
)
3636

@@ -39,9 +39,9 @@ cc_library(
3939
srcs = ["random-handler.cc"],
4040
hdrs = ["random-handler.h"],
4141
deps = [
42-
"//net/proxy:interface",
4342
"@boringssl//:crypto",
4443
"@com_google_absl//absl/container:fixed_array",
44+
"@org_iceboy_trunk//net/interface",
4545
],
4646
)
4747

@@ -50,7 +50,7 @@ cc_library(
5050
srcs = ["zero-handler.cc"],
5151
hdrs = ["zero-handler.h"],
5252
deps = [
53-
"//net/proxy:interface",
5453
"@com_google_absl//absl/container:fixed_array",
54+
"@org_iceboy_trunk//net/interface",
5555
],
5656
)

net/proxy/misc/echo-handler.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef _NET_PROXY_MISC_ECHO_HANDLER_H
22
#define _NET_PROXY_MISC_ECHO_HANDLER_H
33

4-
#include "net/proxy/handler.h"
4+
#include "net/interface/handler.h"
55

66
namespace net {
77
namespace proxy {

net/proxy/misc/null-handler.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef _NET_PROXY_MISC_NULL_HANDLER_H
22
#define _NET_PROXY_MISC_NULL_HANDLER_H
33

4-
#include "net/proxy/handler.h"
4+
#include "net/interface/handler.h"
55

66
namespace net {
77
namespace proxy {

net/proxy/misc/random-handler.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef _NET_PROXY_MISC_RANDOM_HANDLER_H
22
#define _NET_PROXY_MISC_RANDOM_HANDLER_H
33

4-
#include "net/proxy/handler.h"
4+
#include "net/interface/handler.h"
55

66
namespace net {
77
namespace proxy {

net/proxy/misc/zero-handler.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef _NET_PROXY_MISC_ZERO_HANDLER_H
22
#define _NET_PROXY_MISC_ZERO_HANDLER_H
33

4-
#include "net/proxy/handler.h"
4+
#include "net/interface/handler.h"
55

66
namespace net {
77
namespace proxy {

net/proxy/proxy.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
#include "absl/container/flat_hash_map.h"
1111
#include "net/asio.h"
12-
#include "net/proxy/connector.h"
13-
#include "net/proxy/handler.h"
12+
#include "net/interface/connector.h"
13+
#include "net/interface/handler.h"
1414
#include "net/proxy/system/listener.h"
1515

1616
namespace net {

net/proxy/registry.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#include "absl/container/flat_hash_map.h"
99
#include "absl/functional/any_invocable.h"
1010
#include "net/asio.h"
11-
#include "net/proxy/connector.h"
12-
#include "net/proxy/handler.h"
11+
#include "net/interface/connector.h"
12+
#include "net/interface/handler.h"
1313

1414
namespace net {
1515
namespace proxy {

net/proxy/route/BUILD

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ cc_library(
1818
hdrs = ["connector.h"],
1919
deps = [
2020
":host-matcher",
21-
"//net/proxy:interface",
21+
"@org_iceboy_trunk//net/interface",
2222
],
2323
)
2424

0 commit comments

Comments
 (0)