Skip to content

Smcroute is client library for Golang programming language.

License

Notifications You must be signed in to change notification settings

go-x-pkg/smcroute

Repository files navigation

Smcroute

GoDoc Coverage Status Go Report Card

Smcroute is client library for smcroute written in Go programming language.

Library uses unix domain socket for communication.

Tested with [email protected] and [email protected].

Quick-start

$ sudo chmod 777 /var/run/smcroute
package main

import (
  "fmt"

  "github.com/go-x-pkg/smcroute"
)

// sudo smcroute -j eth0.1 239.255.1.1
func main() {
  client := smcroute.NewClient()
  cmdJoin := smcroute.NewCmd(smcroute.CmdJoin, "eth0.1", "239.255.1.1")
  resp, err := client.Exec(cmdJoin)
  fmt.Println(resp, err)
}

Join and leave

$ sudo chmod 777 /var/run/smcroute
$ ip maddr show eth0.1
2:      eth0.1
        link  33:33:00:00:00:01
        link  01:00:5e:00:00:01
        link  33:33:ff:93:e9:07
        link  33:33:00:00:02:02
        inet  224.0.0.1
        inet6 ff02::202
        inet6 ff02::1:ff93:e907
        inet6 ff02::1
        inet6 ff01::1
package main

import (
  "fmt"

  "github.com/go-x-pkg/smcroute"
)

// sudo smcroute -j eth0.1 239.255.1.1
func main() {
  client := smcroute.NewClient()
  cmdJoin := smcroute.NewCmd(smcroute.CmdJoin, "eth0.1", "239.255.1.1")
  resp, err := client.Exec(cmdJoin)
  fmt.Println(resp, err)
}
$ ip maddr show eth0.1
2:      eth0.1
        link  33:33:00:00:00:01
        link  01:00:5e:00:00:01
        link  33:33:ff:93:e9:07
        link  33:33:00:00:02:02
        inet  224.0.0.1
        inet  239.255.1.1        # <--- +1
        inet6 ff02::202
        inet6 ff02::1:ff93:e907
        inet6 ff02::1
        inet6 ff01::1
package main

import (
  "fmt"

  "github.com/go-x-pkg/smcroute"
)

// sudo smcroute -l eth0.1 239.255.1.1
func main() {
  client := smcroute.NewClient()
  cmdLeave := smcroute.NewCmd(smcroute.CmdLeave, "eth0.1", "239.255.1.1")
  resp, e := client.Exec(cmdLeave)
  fmt.Println(resp, e)
}
$ ip maddr show eth0.1
2:      eth0.1
        link  33:33:00:00:00:01
        link  01:00:5e:00:00:01
        link  33:33:ff:93:e9:07
        link  33:33:00:00:02:02
        inet  224.0.0.1
        inet6 ff02::202
        inet6 ff02::1:ff93:e907
        inet6 ff02::1
        inet6 ff01::1

About

Smcroute is client library for Golang programming language.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages