Documentation ¶
Index ¶
- Constants
- Variables
- func BasicAuthenAndAuthor(ctx context.Context) (context.Context, error)
- func ClientCertAuthenAndAuthor(ctx context.Context) (context.Context, error)
- func GenerateJwtSecretKey()
- func GetUserRoles(usr *user.User) ([]string, error)
- func IsNativeOrigin(origin string) bool
- func JwtAuthenAndAuthor(ctx context.Context) (*spb.JwtToken, context.Context, error)
- func PAMAuthUser(u string, p string) error
- func ParseOrigin(paths []*gnmipb.Path) (string, error)
- func PopulateAuthStruct(username string, auth *common_utils.AuthInfo, r []string) error
- func RebootSystem(fileName string) error
- func UserPwAuth(username string, passwd string) (bool, error)
- type AuthTypes
- type Claims
- type Client
- type Config
- type ConnectionManager
- type Credentials
- type Server
- func (srv *Server) Address() string
- func (srv *Server) Authenticate(ctx context.Context, req *spb_jwt.AuthenticateRequest) (*spb_jwt.AuthenticateResponse, error)
- func (srv *Server) CancelReboot(ctx context.Context, req *gnoi_system_pb.CancelRebootRequest) (*gnoi_system_pb.CancelRebootResponse, error)
- func (s *Server) Capabilities(ctx context.Context, req *gnmipb.CapabilityRequest) (*gnmipb.CapabilityResponse, error)
- func (srv *Server) ClearNeighbors(ctx context.Context, req *spb.ClearNeighborsRequest) (*spb.ClearNeighborsResponse, error)
- func (srv *Server) CopyConfig(ctx context.Context, req *spb.CopyConfigRequest) (*spb.CopyConfigResponse, error)
- func (s *Server) Get(ctx context.Context, req *gnmipb.GetRequest) (*gnmipb.GetResponse, error)
- func (srv *Server) ImageDefault(ctx context.Context, req *spb.ImageDefaultRequest) (*spb.ImageDefaultResponse, error)
- func (srv *Server) ImageInstall(ctx context.Context, req *spb.ImageInstallRequest) (*spb.ImageInstallResponse, error)
- func (srv *Server) ImageRemove(ctx context.Context, req *spb.ImageRemoveRequest) (*spb.ImageRemoveResponse, error)
- func (srv *Server) Ping(req *gnoi_system_pb.PingRequest, rs gnoi_system_pb.System_PingServer) error
- func (srv *Server) Port() int64
- func (srv *Server) Reboot(ctx context.Context, req *gnoi_system_pb.RebootRequest) (*gnoi_system_pb.RebootResponse, error)
- func (srv *Server) RebootStatus(ctx context.Context, req *gnoi_system_pb.RebootStatusRequest) (*gnoi_system_pb.RebootStatusResponse, error)
- func (srv *Server) Refresh(ctx context.Context, req *spb_jwt.RefreshRequest) (*spb_jwt.RefreshResponse, error)
- func (srv *Server) Serve() error
- func (s *Server) Set(ctx context.Context, req *gnmipb.SetRequest) (*gnmipb.SetResponse, error)
- func (srv *Server) SetPackage(rs gnoi_system_pb.System_SetPackageServer) error
- func (srv *Server) ShowTechsupport(ctx context.Context, req *spb.TechsupportRequest) (*spb.TechsupportResponse, error)
- func (s *Server) Subscribe(stream gnmipb.GNMI_SubscribeServer) error
- func (srv *Server) SwitchControlProcessor(ctx context.Context, req *gnoi_system_pb.SwitchControlProcessorRequest) (*gnoi_system_pb.SwitchControlProcessorResponse, error)
- func (srv *Server) Time(ctx context.Context, req *gnoi_system_pb.TimeRequest) (*gnoi_system_pb.TimeResponse, error)
- func (srv *Server) Traceroute(req *gnoi_system_pb.TracerouteRequest, ...) error
- type UserCredential
Constants ¶
const ENABLE_NATIVE_WRITE = false
const ENABLE_TRANSLIB_WRITE = false
Variables ¶
var ( JwtRefreshInt time.Duration JwtValidInt time.Duration )
var AuthLock sync.Mutex
Functions ¶
func GenerateJwtSecretKey ¶
func GenerateJwtSecretKey()
func IsNativeOrigin ¶
func JwtAuthenAndAuthor ¶
func PAMAuthUser ¶
func PopulateAuthStruct ¶
func PopulateAuthStruct(username string, auth *common_utils.AuthInfo, r []string) error
func RebootSystem ¶
Types ¶
type Claims ¶
type Claims struct { Username string `json:"username"` Roles []string `json:"roles"` jwt.StandardClaims }
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client contains information about a subscribe client that has connected to the server.
func (*Client) Close ¶
func (c *Client) Close()
Closing of client queue is triggered upon end of stream receive or stream error or fatal error of any client go routine . it will cause cancle of client context and exit of the send goroutines.
func (*Client) Run ¶
func (c *Client) Run(stream gnmipb.GNMI_SubscribeServer) (err error)
Run starts the subscribe client. The first message received must be a SubscriptionList. Once the client is started, it will run until the stream is closed or the schedule completes. For Poll queries the Run will block internally after sync until a Poll request is made to the server.
type Config ¶
type Config struct { // Port for the Server to listen on. If 0 or unset the Server will pick a port // for this Server. Port int64 LogLevel int Threshold int UserAuth AuthTypes EnableTranslibWrite bool EnableNativeWrite bool IdleConnDuration int }
Config is a collection of values for Server
type ConnectionManager ¶
type ConnectionManager struct {
// contains filtered or unexported fields
}
func (*ConnectionManager) GetThreshold ¶
func (cm *ConnectionManager) GetThreshold() int
func (*ConnectionManager) PrepareRedis ¶
func (cm *ConnectionManager) PrepareRedis()
func (*ConnectionManager) Remove ¶
func (cm *ConnectionManager) Remove(key string) bool
type Credentials ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server manages a single gNMI Server implementation. Each client that connects via Subscribe or Get will receive a stream of updates based on the requested path. Set request is processed by server too.
func NewServer ¶
func NewServer(config *Config, opts []grpc.ServerOption) (*Server, error)
New returns an initialized Server.
func (*Server) Authenticate ¶
func (srv *Server) Authenticate(ctx context.Context, req *spb_jwt.AuthenticateRequest) (*spb_jwt.AuthenticateResponse, error)
func (*Server) CancelReboot ¶
func (srv *Server) CancelReboot(ctx context.Context, req *gnoi_system_pb.CancelRebootRequest) (*gnoi_system_pb.CancelRebootResponse, error)
TODO: Support GNOI CancelReboot
func (*Server) Capabilities ¶
func (s *Server) Capabilities(ctx context.Context, req *gnmipb.CapabilityRequest) (*gnmipb.CapabilityResponse, error)
func (*Server) ClearNeighbors ¶
func (srv *Server) ClearNeighbors(ctx context.Context, req *spb.ClearNeighborsRequest) (*spb.ClearNeighborsResponse, error)
func (*Server) CopyConfig ¶
func (srv *Server) CopyConfig(ctx context.Context, req *spb.CopyConfigRequest) (*spb.CopyConfigResponse, error)
func (*Server) Get ¶
func (s *Server) Get(ctx context.Context, req *gnmipb.GetRequest) (*gnmipb.GetResponse, error)
Get implements the Get RPC in gNMI spec.
func (*Server) ImageDefault ¶
func (srv *Server) ImageDefault(ctx context.Context, req *spb.ImageDefaultRequest) (*spb.ImageDefaultResponse, error)
func (*Server) ImageInstall ¶
func (srv *Server) ImageInstall(ctx context.Context, req *spb.ImageInstallRequest) (*spb.ImageInstallResponse, error)
func (*Server) ImageRemove ¶
func (srv *Server) ImageRemove(ctx context.Context, req *spb.ImageRemoveRequest) (*spb.ImageRemoveResponse, error)
func (*Server) Ping ¶
func (srv *Server) Ping(req *gnoi_system_pb.PingRequest, rs gnoi_system_pb.System_PingServer) error
func (*Server) Reboot ¶
func (srv *Server) Reboot(ctx context.Context, req *gnoi_system_pb.RebootRequest) (*gnoi_system_pb.RebootResponse, error)
func (*Server) RebootStatus ¶
func (srv *Server) RebootStatus(ctx context.Context, req *gnoi_system_pb.RebootStatusRequest) (*gnoi_system_pb.RebootStatusResponse, error)
TODO: Support GNOI RebootStatus
func (*Server) Refresh ¶
func (srv *Server) Refresh(ctx context.Context, req *spb_jwt.RefreshRequest) (*spb_jwt.RefreshResponse, error)
func (*Server) Set ¶
func (s *Server) Set(ctx context.Context, req *gnmipb.SetRequest) (*gnmipb.SetResponse, error)
func (*Server) SetPackage ¶
func (srv *Server) SetPackage(rs gnoi_system_pb.System_SetPackageServer) error
func (*Server) ShowTechsupport ¶
func (srv *Server) ShowTechsupport(ctx context.Context, req *spb.TechsupportRequest) (*spb.TechsupportResponse, error)
func (*Server) Subscribe ¶
func (s *Server) Subscribe(stream gnmipb.GNMI_SubscribeServer) error
Subscribe implements the gNMI Subscribe RPC.
func (*Server) SwitchControlProcessor ¶
func (srv *Server) SwitchControlProcessor(ctx context.Context, req *gnoi_system_pb.SwitchControlProcessorRequest) (*gnoi_system_pb.SwitchControlProcessorResponse, error)
func (*Server) Time ¶
func (srv *Server) Time(ctx context.Context, req *gnoi_system_pb.TimeRequest) (*gnoi_system_pb.TimeResponse, error)
func (*Server) Traceroute ¶
func (srv *Server) Traceroute(req *gnoi_system_pb.TracerouteRequest, rs gnoi_system_pb.System_TracerouteServer) error
type UserCredential ¶
func (UserCredential) PAMAuthenticate ¶
func (u UserCredential) PAMAuthenticate() error
PAMAuthenticate performs PAM authentication for the user credentials provided
func (UserCredential) PAMConvHandler ¶
PAM conversation handler.