-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
63 lines (55 loc) · 1.01 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
package main
import (
"os"
"os/user"
"strconv"
dknet "github.com/docker/go-plugins-helpers/network"
i2p "github.com/eyedeekay/docker-i2p-plugin/i2p"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
const (
version = "0.2"
)
func main() {
var flagDebug = cli.BoolFlag{
Name: "debug, d",
Usage: "enable debugging",
}
app := cli.NewApp()
app.Name = "don"
app.Usage = "Docker Open vSwitch Networking"
app.Version = version
app.Flags = []cli.Flag{
flagDebug,
}
app.Action = Run
app.Run(os.Args)
}
func lookupGroup(group string) (gid int, err error) {
g, err := user.LookupGroup(group)
if err != nil {
return 0, err
}
gid, err = strconv.Atoi(g.Gid)
if err != nil {
return 0, err
}
return
}
// Run initializes the driver
func Run(ctx *cli.Context) {
if ctx.Bool("debug") {
log.SetLevel(log.DebugLevel)
}
d, err := i2p.NewDriver()
if err != nil {
panic(err)
}
gid, err := lookupGroup("i2psvc")
if err != nil {
panic(err)
}
h := dknet.NewHandler(d)
h.ServeUnix("root", gid)
}