connection

package
v0.0.1-20231017-0005 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const AuthBasic = 3

AuthBasic -> // Username and Passsword -> which is set in the Header

View Source
const AuthByBearerToken = 2

AuthByBearerToken -> this is the protocol standard -> which is set in the Header

View Source
const AuthByGETParamToken = 4

AuthByGETParamToken -> same Token but attached as GET Param -> which is set as Http GET Param Encrypted format of this auth type is not necessary, because the attacker will anyway get the auth token

View Source
const AuthByToken = 1

AuthByToken -> this is the library default auth type which is set in the Header

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthOptions

type AuthOptions struct {
	// AuthType -> this is the authentication type
	AuthType int `yaml:"auth_type" mapstructure:"auth_type" default:"1"`
	// Token -> it's used by AuthByToken & AuthByBearerToken
	Token string `yaml:"token" mapstructure:"token" default:""`
	// Username -> it's used by AuthBasic
	Username string `yaml:"username" mapstructure:"username" default:""`
	// Password -> it's used by AuthBasic
	Password string `yaml:"password" mapstructure:"password" default:""`
}

type Connection

type Connection struct {
	// Connection params
	IsSecure string `yaml:"is_secure" mapstructure:"is_secure" default:"yes"`
	// Scheme -> wss is encrypted connection!
	Scheme string `yaml:"scheme" mapstructure:"scheme" default:"wss://"`
	Host   string `yaml:"host" mapstructure:"host" default:"localhost"`
	// Port -> the default is 0, in this case no port will be used!
	Port    uint16 `yaml:"port" mapstructure:"port" default:"0"`
	UriPath string `yaml:"uri_path" mapstructure:"uri_path" default:"/"`
	// AcceptCertificate -> Accept Self Signed Certificate
	AcceptCertificate string `yaml:"accept_certificate" mapstructure:"accept_certificate" default:"no"`

	// MaxRetries 0 - means no retries, -1 - means infinite, >0 - means a specific nr of retries:
	// How many times it should retry to connect to same host. It's better to not set to infinite because
	// if you have multiple connections, the infinite param it's better to set on websocket client itself
	MaxRetries int16 `yaml:"max_retries" mapstructure:"max_retries" default:"3"`
	// RetryTimeout -> 5 Seconds by default
	RetryTimeout uint16 `yaml:"retry_timeout" mapstructure:"retry_timeout" default:"5"`

	// Authentication
	// EnableAuth -> If authentication is needed
	EnableAuth string `yaml:"enable_auth" mapstructure:"enable_auth" default:"no"`
	// AuthType -> What type of authentication is needed
	AuthOptions AuthOptions `yaml:"auth_options" mapstructure:"auth_options"`
}

func DefaultConfig

func DefaultConfig(connObj ...*Connection) (Connection, error)

func New

func New() *Connection

NewConnection -> will generate a connection having default values!

func (*Connection) GenerateURL

func (c *Connection) GenerateURL() url.URL

Jump to

Keyboard shortcuts

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