util

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Copyright 2020 Multi-Tier-Cloud Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

Copyright 2020 Multi-Tier-Cloud Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

Copyright 2020 Multi-Tier-Cloud Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

Index

Constants

View Source
const (
	RSA_MIN_BITS = 2048
)

Variables

This section is empty.

Functions

func AddBootstrapFlags

func AddBootstrapFlags() (*[]multiaddr.Multiaddr, error)

Returns address to a slice of strings that will store the bootstrap multiaddresses once flag.Parse() is called (prior to that, it will be an empty slice).

func CreateOrLoadKey

func CreateOrLoadKey(kf KeyFlags) (crypto.PrivKey, error)

func ExpandTilde

func ExpandTilde(path string) (string, error)

Expands tilde to absolute path Currently only works if path begins with tilde, not somewhere in the middle

func FileExists

func FileExists(filePath string) bool

func GeneratePrivKey

func GeneratePrivKey(algo string, bits int) (crypto.PrivKey, error)

func GetBootstrapPointer

func GetBootstrapPointer() *bootstrapAddrs

Don't like this... feels hacky to have a function just for tests in the main package This is needed to return a pointer to type bootstrapAddrs, a hidden type. This enables tests for the Set() and String() functions above.

func GetFreePort

func GetFreePort() (int, error)

Get free port on machine

func GetIPAddress

func GetIPAddress() (string, error)

Get preferred outbound ip on machine

func LoadPrivKeyFromFile

func LoadPrivKeyFromFile(keyFile string) (crypto.PrivKey, error)

Inverse of storePrivKeyToFile()

func StorePrivKeyToFile

func StorePrivKeyToFile(priv crypto.PrivKey, keyFile string) error

Write private key to file in Base 64 format Store the key type ID followed by a space, then the key, then a new-line

Types

type KeyFlags

type KeyFlags struct {
	Algo      *string
	Bits      *int
	Keyfile   *string
	Ephemeral *bool
}

func AddKeyFlags

func AddKeyFlags(defaultKeyFile string) (KeyFlags, error)

Adds CLI arguments for key-related flags. Does not call Parse() on its own.

Takes a single parameter, the default key filename. This allows programs to define different default key filenames, so that if two different programs are run on the same host, they won't read from the same key.

Returns a struct containing pointers to the various variables that will hold the parsed flag values once Parse() is called.

Jump to

Keyboard shortcuts

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