net

package
v0.0.0-...-b8150c1 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2021 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultServerPort is the default listening port for the  server
	DefaultServerPort = 8000

	// DefaultServerAddr is the default listening address for the  server
	DefaultServerAddr = "0.0.0.0"
)
View Source
const (
	// Unknown error code
	ErrUnknown = 0
	// HTTP method not allowed
	ErrMethodNotAllowed = 1
	// No authorization header was found in request
	ErrNoAuthHdr = 2
	// Failed reading the HTTP request body
	ErrReadingReqBody = 3
	// HTTP request body was empty but should not have been
	ErrEmptyReqBody = 4
	// HTTP request body was of the wrong format
	ErrBadReqBody = 5
	// The token in the authorization header was invalid
	ErrBadReqToken = 6
	// The caller does not have the "hf.Revoker" attibute
	ErrNotRevoker = 7
	// Certificate to be revoked was not found
	ErrRevCertNotFound = 8
	// Certificate to be revoked is not owned by expected user
	ErrCertWrongOwner = 9
	// Identity of certificate to be revoked was not found
	ErrRevokeIDNotFound = 10
	// User info was not found for issuee of revoked certificate
	ErrRevokeUserInfoNotFound = 11
	// Certificate revocation failed for another reason
	ErrRevokeFailure = 12
	// Failed to update user info when revoking identity
	ErrRevokeUpdateUser = 13
	// Failed to revoke any certificates by identity
	ErrNoCertsRevoked = 14
	// Missing fields in the revocation request
	ErrMissingRevokeArgs = 15
	// Failed to get user's affiliation
	ErrGettingAffiliation = 16
	// Revoker's affiliation not equal to or above revokee's affiliation
	ErrRevokerNotAffiliated = 17
	// Failed to send an HTTP response
	ErrSendingResponse = 18
	// The CA (Certificate Authority) name was not found
	ErrCANotFound = 19
	// Authorization failure
	ErrAuthFailure = 20
	// No username and password were in the authorization header
	ErrNoUserPass = 21
	// Enrollment is currently disabled for the server
	ErrEnrollDisabled = 22
	// Invalid user name
	ErrInvalidUser = 23
	// Invalid password
	ErrInvalidPass = 24
	// Invalid token in authorization header
	ErrInvalidToken = 25
	// Certificate was not issued by a trusted authority
	ErrUntrustedCertificate = 26
	// Certificate has expired
	ErrCertExpired = 27
	// Certificate has been revoked
	ErrCertRevoked = 28
	// Failed trying to check if certificate is revoked
	ErrCertRevokeCheckFailure = 29
	// Certificate was not found
	ErrCertNotFound = 30
	// Bad certificate signing request
	ErrBadCSR = 31
	// Failed to get identity's prekey
	ErrNoPreKey = 32
	// The caller was not authenticated
	ErrCallerIsNotAuthenticated = 33
	// Invalid configuration setting
	ErrConfig = 34
	// The caller does not have authority to generate a CRL
	ErrNoGenCRLAuth = 35
	// Invalid RevokedAfter value in the GenCRL request
	ErrInvalidRevokedAfter = 36
	// Invalid ExpiredAfter value in the GenCRL request
	ErrInvalidExpiredAfter = 37
	// Failed to get revoked certs from the database
	ErrRevokedCertsFromDB = 38
	// Failed to get CA cert
	ErrGetCACert = 39
	// Failed to get CA signer
	ErrGetCASigner = 40
	// Failed to generate CRL
	ErrGenCRL = 41
	// Registrar does not have the authority to register an attribute
	ErrRegAttrAuth = 42
	// Registrar does not own 'hf.Registrar.Attributes'
	ErrMissingRegAttr = 43
	// Caller does not have appropriate affiliation to perform requested action
	ErrCallerNotAffiliated = 44
	// Failed to verify if caller has appropriate type
	ErrGettingType = 45
	// CA cert does not have 'crl sign' usage
	ErrNoCrlSignAuth = 46
	// Incorrect level of database
	ErrDBLevel = 47
	// Incorrect level of configuration file
	ErrConfigFileLevel = 48
	// Failed to get user from database
	ErrGettingUser = 49
	// Error processing HTTP request
	ErrHTTPRequest = 50
	// Error connecting to database
	ErrConnectingDB = 51
	// Failed to add identity
	ErrAddIdentity = 52
	// Unauthorized to perform update action
	ErrUpdateConfigAuth = 53
	// Registrar not authorized to act on type
	ErrRegistrarInvalidType = 54
	// Registrar not authorized to act on affiliation
	ErrRegistrarNotAffiliated = 55
	// Failed to remove identity
	ErrRemoveIdentity = 56
	// Failed to get boolean query parameter
	ErrGettingBoolQueryParm = 57
	// Failed to modify identity
	ErrModifyingIdentity = 58
	// Caller does not have the appropriate role
	ErrMissingRole = 59
	// Failed to add new affiliation
	ErrUpdateConfigAddAff = 60
	// Failed to remove affiliation
	ErrUpdateConfigRemoveAff = 61
	// Error occured while removing affiliation in database
	ErrRemoveAffDB = 62
	// Error occured when making a Get request to database
	ErrDBGet = 63
	// Failed to modiy affiliation
	ErrUpdateConfigModifyAff = 64
	// Error occured while deleting user
	ErrDBDeleteUser = 65
	// Certificate that is being revoked has already been revoked
	ErrCertAlreadyRevoked = 66
	// Failed to get requested certificate(s)
	ErrGettingCert = 67
	// Error occurred parsing variable as an integer
	ErrParsingIntEnvVar = 68
	// CA certificate file is not found warning message
	ErrCACertFileNotFound = 69
)

Variables

View Source
var (
	Nodes          = 1
	Urls  []string = []string{"http://192.168.72.1:8000"}

	Ports  string
	Sender string = "windows"

	Testflag = ""
)

Functions

func Broadcast

func Broadcast(s string, reqBody []byte) error

func Flushall

func Flushall()

func Init

func Init()

func IsSmartContract

func IsSmartContract(tx *common.Transaction) bool

func NewPost

func NewPost(endPoint string, reqBody []byte) (*http.Request, error)

func SendTrans

func SendTrans()

Types

type BlockState

type BlockState struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*BlockState) CheckAndStore

func (bs *BlockState) CheckAndStore(hash string)

func (*BlockState) Checkblock

func (bs *BlockState) Checkblock(b *common.Block) bool

func (*BlockState) Checks

func (bs *BlockState) Checks(hash string) bool

func (*BlockState) GetCurrB

func (bs *BlockState) GetCurrB() common.Block

func (*BlockState) GetTmpB

func (bs *BlockState) GetTmpB() common.Block

func (*BlockState) SetCurrB

func (bs *BlockState) SetCurrB(b common.Block)

func (*BlockState) SetTmpB

func (bs *BlockState) SetTmpB(b common.Block)

func (*BlockState) StoreBlock

func (bs *BlockState) StoreBlock()

type Client

type Client struct {
	Url string
	// contains filtered or unexported fields
}

func (*Client) SendReq

func (c *Client) SendReq(req *http.Request, result interface{}) (err error)

type LcCommand

type LcCommand struct {
	Command string
	SCNAME  string
	Version string
	Data    []byte
}

type Req

type Req struct {
}

type SCInStatus

type SCInStatus struct {
	SCNAME string
	Status string
}

type SCIns

type SCIns struct {
	SCNAME  string
	CREATER string
	Version string
	Data    []byte
}

type Server

type Server struct {
	// The home directory for the server
	HomeDir string
	// BlockingStart if true makes the Start function blocking;
	// It is non-blocking by default.
	BlockingStart bool
	// The server's configuration
	Config *ServerConfig
	// contains filtered or unexported fields
}

func (*Server) Init

func (s *Server) Init(renew bool) (err error)

func (*Server) Start

func (s *Server) Start() (err error)

func (*Server) Stop

func (s *Server) Stop() error

Stop the server WARNING: This forcefully closes the listening socket and may cause requests in transit to fail, and so is only used for testing. A graceful shutdown will be supported with golang 1.8.

type ServerConfig

type ServerConfig struct {
	// Listening port for the server
	Port int `def:"8000" opt:"p" help:"Listening port of server"`
	// Bind address for the server
	Address string `def:"0.0.0.0" help:"Listening address of server"`
	// Enables debug logging
	Debug bool `def:"false" opt:"d" help:"Enable debug level logging"`
}

type SmartContractDefinition

type SmartContractDefinition struct {
	SCNAME  string
	Hash    string
	Version string
}

type SmartContractInit

type SmartContractInit struct {
	SCNAME  string
	CREATER string
	Version string
	Data    []byte
}

func GenerateSCSpec

func GenerateSCSpec(lcc *LcCommand, creater string) (*SmartContractInit, error)

type TestInfo

type TestInfo struct {
	TName string

	Version string
}

type TestInfoResponseNet

type TestInfoResponseNet struct {
	TName string

	Version string
}

Jump to

Keyboard shortcuts

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