-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
flesh out the web package and transition to worker abstraction
- Loading branch information
Showing
17 changed files
with
424 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,7 @@ shotis-node | |
shotis-*.json | ||
.DS_Store | ||
*.png | ||
*.mov | ||
*.mov | ||
*.crt | ||
*.csr | ||
*.key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
{ | ||
"peers": [ | ||
"grpc://192.168.0.1:1337" | ||
], | ||
"grpc": { | ||
"tlsEnabled": false, | ||
"rpc":"", | ||
"server": { | ||
"tls": { | ||
"key": "some_key.key", | ||
"cert": "some_cert.cert" | ||
} | ||
"enabled": false, | ||
"key": "shotis.key", | ||
"cert": "shotis.crt" | ||
}, | ||
"web": { | ||
"maxStreams": 250 | ||
}, | ||
"rpc":{ | ||
"host": ":1337" | ||
}, | ||
"host": ":443" | ||
}, | ||
"storage": { | ||
"bucket": "", | ||
"key": "" | ||
"bucket": "shot_is_image_1", | ||
"authKey": "shotis-2ab802400c4e.json" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package config | ||
|
||
import ( | ||
"encoding/json" | ||
"io/ioutil" | ||
) | ||
|
||
type NodeConfig struct { | ||
Server *ServerConfig `json:"server"` | ||
// The storage | ||
Storage *StorageConfig `json:"storage"` | ||
} | ||
|
||
type RPCConfig struct { | ||
Host string | ||
} | ||
|
||
type TLSConfig struct { | ||
Enabled bool `json:"enabled"` | ||
KeyPath string `json:"key"` | ||
CertPath string `json:"cert"` | ||
} | ||
|
||
type ServerConfig struct { | ||
// The RPC server that should be connected to | ||
RPC *RPCConfig `json:"rpc"` | ||
TLS *TLSConfig `json:"tls"` | ||
Web *WebConfig | ||
Host string `json:"host"` | ||
} | ||
|
||
type StorageConfig struct { | ||
Bucket string `json:"bucket"` | ||
AuthKey string `json:"authKey"` | ||
} | ||
|
||
type WebConfig struct { | ||
MaxStreams int `json:"maxStreams"` | ||
} | ||
|
||
func ReadConfig(configPath string) (*NodeConfig, error) { | ||
var conf NodeConfig | ||
|
||
confFile, err := ioutil.ReadFile(configPath) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
err = json.Unmarshal(confFile, &conf) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &conf, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package crypto | ||
|
||
import ( | ||
"crypto/x509" | ||
"encoding/pem" | ||
"io/ioutil" | ||
) | ||
|
||
func SingleCertificatePool(certFile string) (*x509.CertPool, error) { | ||
pemCert, err := ioutil.ReadFile(certFile) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
pemBlock, _ := pem.Decode(pemCert) | ||
cert, err := x509.ParseCertificate(pemBlock.Bytes) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
certPool := x509.NewCertPool() | ||
certPool.AddCert(cert) | ||
return certPool, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.