feat: init commit
This commit is contained in:
25
bin/config.dart
Normal file
25
bin/config.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class HostAndPort {
|
||||
String host;
|
||||
int port;
|
||||
}
|
||||
|
||||
class ManageConfig {
|
||||
String listen;
|
||||
}
|
||||
|
||||
class ProxyItemConfig {
|
||||
String listen;
|
||||
String backend;
|
||||
List<String> allowIps;
|
||||
}
|
||||
|
||||
class ProxyConfig {
|
||||
ManageConfig managementConfig;
|
||||
List<ProxyItemConfig> tcpListens;
|
||||
}
|
||||
|
||||
ProxyConfig parseProxyConfig(String config) {
|
||||
final jsonConfig = json.decode(config);
|
||||
}
|
||||
22
bin/simple_dart_tcp_proxy.dart
Normal file
22
bin/simple_dart_tcp_proxy.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'config.dart';
|
||||
|
||||
void main(List<String> arguments) {
|
||||
final listenAddress = "127.0.0.1";
|
||||
final listenPort = 8801;
|
||||
final targetHost = "";
|
||||
final targetPort = 443;
|
||||
|
||||
// TODO ...
|
||||
print('Hello world!');
|
||||
}
|
||||
|
||||
void startListen(HostAndPort listen, HostAndPort target) {
|
||||
ServerSocket.bind(listen.host, listen.port).then((serverSocket) {
|
||||
Socket.connect(target.host, target.port).then((clientSocket) {
|
||||
// TODO ...
|
||||
});
|
||||
// serverSocket.listen((event) { })
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user