aboutsummaryrefslogtreecommitdiffstats
path: root/gosrc/main.go
blob: 9923d0966360326f544ac8290ca7597b427bd41c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//   SMITH            (  //       /
//   main              ( )/       /
//   by salade         )(/        /
//  ________________  ( /)        /
// ()__)____________)))))   :^}   /

package main

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"log"
	"os"
)

// #include "../csrc/smith.h"
// #cgo LDFLAGS: -lsmith -L../
import "C"

type Config struct {
    Public_key string
	Secret_key string
	Mirror string
}

func main() {
	fmt.Println("Welcome, traveller, my name is " + Styles.colorGreen + C.GoString(C.mr_smith()) + Styles.colorReset +
	"\nI will try to help you get the bag...")

	config_path := "./config.json"
	for i, a := range os.Args[1:] {
		if a == "-c" || a == "--config" {
			config_path = os.Args[i + 2]
		}
	}

	config_content, err := ioutil.ReadFile(config_path)
	if err != nil {
		log.Fatal("config file not found")
	}

	var config Config
	err = json.Unmarshal(config_content, &config)
	if err != nil {
		log.Fatal("error during marshall() ", err)
	}

	fmt.Println("\n" +
		Styles.colorBlue + "public_key: " + Styles.colorReset + config.Public_key + "\n" +
		Styles.colorBlue + "secret_key: " + Styles.colorReset + config.Secret_key + "\n" +
		Styles.colorBlue + "mirror:     " + Styles.colorReset + config.Mirror)

	make_body("qwe", "qwe", "qwe")
}