config

package
v0.0.0-...-17dc85b Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NatConfiguration

type NatConfiguration struct {
	Gateway      string `yaml:"gateway" env:"PROTRANS_NAT_GATEWAY"`
	PortLifetime uint16 `yaml:"port_lifetime" env:"PROTRANS_NAT_PORT_LIFETIME"`
}

func (*NatConfiguration) String

func (nc *NatConfiguration) String() string
Example
package main

import (
	"fmt"

	"github.com/massix/protrans/internal/config"
)

func main() {
	nc := &config.NatConfiguration{
		Gateway:      "10.0.2.1",
		PortLifetime: 600,
	}

	fmt.Print(nc)

}
Output:

Nat{Gateway="10.0.2.1" PortLifetime=600}

type ProtransConfiguration

type ProtransConfiguration struct {
	Transmission *TransmissionConfiguration `yaml:"transmission"`
	Nat          *NatConfiguration          `yaml:"nat"`
	LogLevel     string                     `yaml:"log_level" env:"PROTRANS_LOG_LEVEL"`
}

func New

func New(filePath string, shouldUseEnvironment bool) *ProtransConfiguration

func (*ProtransConfiguration) GatewayIP

func (c *ProtransConfiguration) GatewayIP() net.IP

func (*ProtransConfiguration) LogrusLogLevel

func (c *ProtransConfiguration) LogrusLogLevel() (level logrus.Level)

func (*ProtransConfiguration) String

func (pc *ProtransConfiguration) String() string
Example
package main

import (
	"fmt"

	"github.com/massix/protrans/internal/config"
)

func main() {
	ptc := &config.ProtransConfiguration{
		Transmission: &config.TransmissionConfiguration{
			Host:     "192.168.1.2",
			Port:     8080,
			Username: "",
			Password: "",
		},
		Nat: &config.NatConfiguration{
			Gateway:      "10.42.3.1",
			PortLifetime: 126,
		},
		LogLevel: "DEBUG",
	}

	fmt.Print(ptc)

}
Output:

ProTrans{LogLevel="DEBUG" Nat{Gateway="10.42.3.1" PortLifetime=126} Transmission{Host="192.168.1.2" Port=8080 Username="" Password="not set"}}

type TransmissionConfiguration

type TransmissionConfiguration struct {
	Host     string `yaml:"host" env:"PROTRANS_TRANSMISSION_HOST"`
	Port     uint16 `yaml:"port" env:"PROTRANS_TRANSMISSION_PORT"`
	Username string `yaml:"username" env:"PROTRANS_TRANSMISSION_USERNAME"`
	Password string `yaml:"password" env:"PROTRANS_TRANSMISSION_PASSWORD"`
}

func (*TransmissionConfiguration) String

func (tc *TransmissionConfiguration) String() string
Example
package main

import (
	"fmt"

	"github.com/massix/protrans/internal/config"
)

func main() {
	tc := &config.TransmissionConfiguration{
		Host:     "localhost",
		Port:     9091,
		Username: "SomeUser",
		Password: "WithPassword",
	}

	fmt.Print(tc.String())

}
Output:

Transmission{Host="localhost" Port=9091 Username="SomeUser" Password="set"}

Jump to

Keyboard shortcuts

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