commit c862532b2d745b622590cf9ac493e46999a0aabb Author: Kleissner Date: Thu May 19 02:09:29 2022 +0200 Initial code for this new Peernet client. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2f480b9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.exe +*debug_bin +*.yaml +.vscode +data/ \ No newline at end of file diff --git a/Main.go b/Main.go new file mode 100644 index 0000000..6826594 --- /dev/null +++ b/Main.go @@ -0,0 +1,55 @@ +/* +File Name: Main.go +Copyright: 2021 Peernet s.r.o. +Author: Peter Kleissner +*/ + +package main + +import ( + "fmt" + "os" + + "github.com/PeernetOfficial/core" +) + +const configFile = "Config.yaml" +const appName = "Peernet Web Gateway" + +var config struct { + // HTTP settings for the web gateway + WebListen []string `yaml:"WebListen"` // WebListen is in format IP:Port and declares where the web-interface should listen on. IP can also be ommitted to listen on any. + WebUseSSL bool `yaml:"WebUseSSL"` // Enables SSL. + WebCertificateFile string `yaml:"WebCertificateFile"` // This is the certificate received from the CA. This can also include the intermediate certificate from the CA. + WebCertificateKey string `yaml:"WebCertificateKey"` // This is the private key. + WebTimeoutRead string `yaml:"WebTimeoutRead"` // The maximum duration for reading the entire request, including the body. + WebTimeoutWrite string `yaml:"WebTimeoutWrite"` // The maximum duration before timing out writes of the response. This includes processing time and is therefore the max time any HTTP function may take. +} + +func main() { + userAgent := appName + "/" + core.Version + + backend, status, err := core.Init(userAgent, configFile, nil, &config) + + if status != core.ExitSuccess { + switch status { + case core.ExitErrorConfigAccess: + fmt.Printf("Unknown error accessing config file '%s': %s\n", configFile, err.Error()) + case core.ExitErrorConfigRead: + fmt.Printf("Error reading config file '%s': %s\n", configFile, err.Error()) + case core.ExitErrorConfigParse: + fmt.Printf("Error parsing config file '%s' (make sure it is valid YAML format): %s\n", configFile, err.Error()) + case core.ExitErrorLogInit: + fmt.Printf("Error opening log file '%s': %s\n", backend.Config.LogFile, err.Error()) + default: + fmt.Printf("Unknown error %d initializing backend: %s\n", status, err.Error()) + } + os.Exit(status) + } + + backend.Stdout.Subscribe(os.Stdout) + + //startWebGateway(backend, ) + + backend.Connect() +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..fd78a4c --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +# Peernet Web Gateway + +This Web Gateway is a regular Peernet client that provides a web gateway to Peernet. It allows to access files in Peernet through an open website. Accessing files via this web gateway is useful for regular web 2 users. For example, one can share a file on Peernet and then use this web gateway to make it accessible on Twitter. + +## Compile + +Download the [latest version of Go](https://golang.org/dl/). To build: + +``` +go build +``` + +## Deploy + +Todo. + +## Config + +The config filename is hard-coded to `Config.yaml` and is created on the first run. Please see the [core library](https://github.com/PeernetOfficial/core#configuration) for individual settings to change. + +Todo. + +## API + +Todo. + diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..39c8305 --- /dev/null +++ b/go.mod @@ -0,0 +1,17 @@ +module github.com/PeernetOfficial/Cmd + +go 1.18 + +require github.com/PeernetOfficial/core v0.0.0-20220329002833-346f38c61138 + +require ( + github.com/akrylysov/pogreb v0.10.1 // indirect + github.com/enfipy/locker v1.1.0 // indirect + github.com/google/uuid v1.3.0 // indirect + github.com/klauspost/cpuid/v2 v2.0.12 // indirect + golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064 // indirect + golang.org/x/net v0.0.0-20220325170049-de3da57026de // indirect + golang.org/x/sys v0.0.0-20220325203850-36772127a21f // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect + lukechampine.com/blake3 v1.1.7 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..3276ca1 --- /dev/null +++ b/go.sum @@ -0,0 +1,23 @@ +github.com/PeernetOfficial/core v0.0.0-20220329002833-346f38c61138 h1:AhFNcWzqLU/LXRN4qsCkhX4+oH1LuJPCHBkvAYNDnMI= +github.com/PeernetOfficial/core v0.0.0-20220329002833-346f38c61138/go.mod h1:X2a4/PoJKp0UWnaUZRa6sg+TrMgyNp9b3hj7axyQRuE= +github.com/akrylysov/pogreb v0.10.1 h1:FqlR8VR7uCbJdfUob916tPM+idpKgeESDXOA1K0DK4w= +github.com/akrylysov/pogreb v0.10.1/go.mod h1:pNs6QmpQ1UlTJKDezuRWmaqkgUE2TuU0YTWyqJZ7+lI= +github.com/enfipy/locker v1.1.0 h1:2zVJ0ky7cS1Vjs0x6OQWFiT2dSEiHrI5/O2KCz1fgGc= +github.com/enfipy/locker v1.1.0/go.mod h1:uuj+dvWHECshK8rkHcw+ZOb9SLo16yc0Em/JGUqRqko= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.0.12 h1:p9dKCg8i4gmOxtv35DvrYoWqYzQrvEVdjQ762Y0OqZE= +github.com/klauspost/cpuid/v2 v2.0.12/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c= +golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064 h1:S25/rfnfsMVgORT4/J61MJ7rdyseOZOyvLIrZEZ7s6s= +golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/net v0.0.0-20220325170049-de3da57026de h1:pZB1TWnKi+o4bENlbzAgLrEbY4RMYmUIRobMcSmfeYc= +golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/sys v0.0.0-20220325203850-36772127a21f h1:TrmogKRsSOxRMJbLYGrB4SBbW+LJcEllYBLME5Zk5pU= +golang.org/x/sys v0.0.0-20220325203850-36772127a21f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +lukechampine.com/blake3 v1.1.7 h1:GgRMhmdsuK8+ii6UZFDL8Nb+VyMwadAgcJyfYHxG6n0= +lukechampine.com/blake3 v1.1.7/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA=