Skip to content

Releases: moznion/go-iprtb

v0.5.0

02 Dec 10:22
6b9df59
Compare
Choose a tag to compare

New Features

Support JSON marshalling and unmarshalling for the Route struct value #14

Examples

Marshalling

func ExampleRoute_MarshalJSON() {
	r := &Route{
		Destination: &net.IPNet{
			IP:   net.IPv4(192, 0, 2, 0).To4(),
			Mask: net.IPv4Mask(255, 255, 255, 0),
		},
		Gateway:          net.IPv4(192, 0, 2, 1),
		NetworkInterface: "ifb0",
		Metric:           1,
	}

	marshalled, err := json.Marshal(r)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%s\n", marshalled)

	// Output:
	// {"destination":"192.0.2.0/24","gateway":"192.0.2.1","networkInterface":"ifb0","metric":1}
}

Unmarshalling

func ExampleRoute_UnmarshalJSON() {
	var r Route
	err := json.Unmarshal([]byte(`{"destination":"192.0.2.0/24","gateway":"192.0.2.1","networkInterface":"ifb0","metric":1}`), &r)
	if err != nil {
		panic(err)
	}

	fmt.Printf("destination: %s\n", r.Destination.String())
	fmt.Printf("gateway: %s\n", r.Gateway.String())
	fmt.Printf("networkInterface: %s\n", r.NetworkInterface)
	fmt.Printf("metric: %d\n", r.Metric)

	// Output:
	// destination: 192.0.2.0/24
	// gateway: 192.0.2.1
	// networkInterface: ifb0
	// metric: 1
}

v0.4.0

22 Nov 03:56
2fe6bb1
Compare
Choose a tag to compare

Breaking Changes

  • Return the removed route information by the route removing methods #13

v0.3.1

22 Nov 03:53
a6565d4
Compare
Choose a tag to compare

Bug Fixes

  • Fix a node pruning bug that removes active node (i.e. the node that has child) unexpectedly #12

Maintenance

  • Update module github.com/moznion/go-optional to v0.8.0 #11

v0.3.0

15 Nov 08:14
b40127e
Compare
Choose a tag to compare

Breaking Changes

  • Receive a context.Context at the first argument on each RouteTable method #10

v0.2.1

14 Nov 01:58
0b850b4
Compare
Choose a tag to compare

Performance Improvements

Prune a non-terminated branch on route removal #8

This change makes it prune a non-terminated branch on route removal. This change brings up better performance for routes searching like the following benchmark result:

$ go test -bench=. -benchmem
goos: linux
goarch: amd64
pkg: github.com/moznion/go-iprtb
cpu: 12th Gen Intel(R) Core(TM) i7-1280P
Benchmark_New-20        211061150                5.562 ns/op           0 B/op          0 allocs/op
Benchmark_Old-20        29355026                40.87 ns/op            0 B/op          0 allocs/op
PASS
ok      github.com/moznion/go-iprtb     2.999s

Maintenance

  • Simplify the logic in addRoute() #9

v0.2.0

13 Nov 01:22
b55505e
Compare
Choose a tag to compare

What's Changed

Breaking Changes

  • Change the signatures that use net.IPNet #4

New Features

  • Add an operation "ClearRoutes" to remove all routes from the routing table #5
  • Remove an associated label mapping when it removes by RemoveRoute() instead of RemoveRouteByLabel() #6

Maintenance

  • Organize the code structure #3

v0.1.0

12 Nov 09:34
aee58bf
Compare
Choose a tag to compare

Initial Release