diff --git a/.gitignore b/.gitignore index 7498fb0..710bf8d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.idea/ # ---> Dart # See https://www.dartlang.org/guides/libraries/private-files diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..687440b --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +- Initial version, created by Stagehand diff --git a/README.md b/README.md index 527ce68..1a96d25 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ -# simple-dart-tcp-proxy +A simple command-line application. +Created from templates made available by Stagehand under a BSD-style +[license](https://github.com/dart-lang/stagehand/blob/master/LICENSE). diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..a686c1b --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,14 @@ +# Defines a default set of lint rules enforced for +# projects at Google. For details and rationale, +# see https://github.com/dart-lang/pedantic#enabled-lints. +include: package:pedantic/analysis_options.yaml + +# For lint rules and documentation, see http://dart-lang.github.io/linter/lints. +# Uncomment to specify additional rules. +# linter: +# rules: +# - camel_case_types + +analyzer: +# exclude: +# - path/to/excluded/files/** diff --git a/bin/config.dart b/bin/config.dart new file mode 100644 index 0000000..2ae6021 --- /dev/null +++ b/bin/config.dart @@ -0,0 +1,25 @@ +import 'dart:convert'; + +class HostAndPort { + String host; + int port; +} + +class ManageConfig { + String listen; +} + +class ProxyItemConfig { + String listen; + String backend; + List allowIps; +} + +class ProxyConfig { + ManageConfig managementConfig; + List tcpListens; +} + +ProxyConfig parseProxyConfig(String config) { + final jsonConfig = json.decode(config); +} diff --git a/bin/simple_dart_tcp_proxy.dart b/bin/simple_dart_tcp_proxy.dart new file mode 100644 index 0000000..314be67 --- /dev/null +++ b/bin/simple_dart_tcp_proxy.dart @@ -0,0 +1,22 @@ +import 'dart:convert'; +import 'dart:io'; +import 'config.dart'; + +void main(List 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) { }) + }); +} diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 0000000..72d14b3 --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,13 @@ +name: simple_dart_tcp_proxy +description: A simple command-line application. +# version: 1.0.0 +# homepage: https://www.example.com + +environment: + sdk: '>=2.8.1 <3.0.0' + +#dependencies: +# path: ^1.7.0 + +dev_dependencies: + pedantic: ^1.9.0