-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
92 lines (83 loc) · 2.2 KB
/
main.go
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package main
// Copyright 2022- Emin Muhammadi and contributors
//
// Licensed under the The GNU Affero General Public License,
// Version 3.0 (the "License"); you may not use this file except
// in compliance with the License. You may obtain a copy
// of the License at
//
// https://www.gnu.org/licenses/agpl-3.0.en.html
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
import (
"encoding/json"
"fmt"
"log"
"os"
"time"
cmd "github.com/eminmuhammadi/xtunnel/cmd"
cli "github.com/urfave/cli/v2"
)
var (
VERSION = "0.0.1-development"
BUILD_TIME = ""
GO_VERSION = ""
)
var commands = []*cli.Command{
cmd.Forward(),
}
// Metadata for current release
const METADATA string = `{
"name": "xtunnel",
"description": "TCP/UDP/Unix reverse tunneling tool",
"version": "%s",
"author": {
"name": "Emin Muhammadi",
"email": "[email protected]"
},
"copyright": "(c) %d Emin Muhammadi and contributors",
"license": "The GNU Affero General Public License"
}`
// Entry point for the application
func main() {
// parse METADATA
var md struct {
Name string `json:"name"`
Description string `json:"description"`
Version string `json:"version"`
Author struct {
Name string `json:"name"`
Email string `json:"email"`
} `json:"author"`
Copyright string `json:"copyright"`
License string `json:"license"`
}
json.Unmarshal([]byte(METADATA), &md)
app := &cli.App{
Name: md.Name,
Usage: md.Description,
Version: fmt.Sprintf(md.Version, VERSION),
Authors: []*cli.Author{{
Name: md.Author.Name,
Email: md.Author.Email,
}},
Copyright: fmt.Sprintf(md.Copyright, time.Now().Year()),
ExtraInfo: func() map[string]string {
return map[string]string{
"LICENSE": md.License,
"BUILD_TIME": BUILD_TIME,
"GO_VERSION": GO_VERSION,
}
},
Commands: commands,
Suggest: true,
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}