routeros

package module
v0.1.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2025 License: MIT Imports: 5 Imported by: 0

README

About

SDK that contain implementation of Router OS. This made to wrap router-os into structure that help developer to know the data returned.

Example

    routerBuilder := routeros.NewRouterOS(&routeros.Options{
		Address:  "<your ip>:8728",
		Username: "<your user-name>",
		Password: "<your password>",
	})
	err := routerBuilder.Connect()
	if err != nil {
		log.Fatal(err)
	}
	defer routerBuilder.Close()

	active, err := driver.New(routerBuilder, module.HotspotModule)
	if err != nil {
		log.Fatal(err)
	}

	// Example of using Print
	activeRes, err := active.Print(context.Background(), model.PrintRequest{
		Where: []model.Where{
			{
			 	Field:    "address",
			 	Value:    "10.10.10.53",
			 	Operator: model.OperatorEqual,
			},
		},
	})
	if err != nil {
		log.Fatal(err)
	}
	for _, a := range activeRes {
		fmt.Println(a)
	}

Roadmap

We have a lot of things to provide all API on this SDK. Currently, I work by my priority like this.

  • IP
  • System

Support

If you love this respository, don't forge to support me.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Address       string
	Username      string
	Password      string
	Timeout       time.Duration
	AutoReconnect bool
}

type RouterOS

type RouterOS struct {
	// contains filtered or unexported fields
}

func NewAndConnctRouterOS

func NewAndConnctRouterOS(opt *Options) (*RouterOS, error)

NewAndConnctRouterOS creates a new RouterOS client and connects to the router.

func NewRouterOS

func NewRouterOS(opt *Options) *RouterOS

func (*RouterOS) Async

func (r *RouterOS) Async()

Async starts asynchronous mode and returns immediately..

func (*RouterOS) CallContext

func (r *RouterOS) CallContext(ctx context.Context, sentence ...string) (*routeros.Reply, error)

Run runs a sentence on the router.

func (*RouterOS) Close

func (r *RouterOS) Close() error

Close the connection to the router.

func (*RouterOS) Connect

func (r *RouterOS) Connect() error

Connect connects to the router.

func (*RouterOS) GetPath

func (r *RouterOS) GetPath() string

GetQuery returns the query of the builder.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL