mirror of
https://github.com/jpillora/chisel
synced 2026-06-08 15:07:02 +00:00
29 lines
425 B
Go
29 lines
425 B
Go
package chisel
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
)
|
|
|
|
type Config struct {
|
|
Version string
|
|
Auth string
|
|
Server string
|
|
Remotes []*Remote
|
|
}
|
|
|
|
const ConfigPrefix = "chisel"
|
|
|
|
func DecodeConfig(b []byte) (*Config, error) {
|
|
c := &Config{}
|
|
err := json.Unmarshal(b, c)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("Invalid JSON config")
|
|
}
|
|
return c, nil
|
|
}
|
|
|
|
func EncodeConfig(c *Config) ([]byte, error) {
|
|
return json.Marshal(c)
|
|
}
|