httpoverrpc

package
v1.40.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

README

HTTPOVERRPC

This directory contains the http over rpc services. It is a simple service that allows to send http requests to from target hosts

Usage

sanssh httpoverrpc get

Make a HTTP(-S) request to a specified port on the remote host.

sanssh <sanssh-args> get [-method <method>] [-header <header>] [-dial-address <dial-address>] [-insecure-skip-tls-verify] [-show-response-headers] [-body <body>] [-protocol <protocol>] [-hostname <hostname>] <remoteport> <request_uri>:

Where:

  • <body> body to send in request
  • <dial-address> host:port to dial to. If not provided would dial to original host and port
  • <header> Header to send in the request, may be specified multiple times.
  • <hostname> ip address or domain name to specify host (default "localhost")
  • <method> method to use in the HTTP request (default "GET")
  • <protocol> protocol to communicate with specified hostname (default "http")
  • <remoteport> port to connect to on the remote host
  • <request_uri> URI to request

Flags:

  • -show-response-headers If provided, print response code and headers
  • -insecure-skip-tls-verify If provided, skip TLS verification

Note:

  1. The prefix / in request_uri is always needed, even there is nothing to put
  2. If we use --hostname to send requests to a specified host instead of the default localhost, and want to use sansshell proxy action to proxy requests, don't forget to add --allow-any-host for proxy action

Examples:

# send get request to https://10.1.23.4:9090/hello
httpoverrpc get --hostname 10.1.23.4 --protocol https 9090 /hello
# send get request with url http://example.com:9090/hello, but deal to localhost:9090
httpoverrpc get --hostname example.com --dialAddress localhost:9090 9090 /hello

Documentation

Overview

Package httpoverrpc defines the RPC interface for the sansshell HTTP actions.

Index

Constants

View Source
const (
	HTTPOverRPC_Host_FullMethodName = "/HTTPOverRPC.HTTPOverRPC/Host"
)

Variables

View Source
var File_httpoverrpc_proto protoreflect.FileDescriptor
View Source
var HTTPOverRPC_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "HTTPOverRPC.HTTPOverRPC",
	HandlerType: (*HTTPOverRPCServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Host",
			Handler:    _HTTPOverRPC_Host_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "httpoverrpc.proto",
}

HTTPOverRPC_ServiceDesc is the grpc.ServiceDesc for HTTPOverRPC service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterHTTPOverRPCServer

func RegisterHTTPOverRPCServer(s grpc.ServiceRegistrar, srv HTTPOverRPCServer)

Types

type DialConfig added in v1.39.0

type DialConfig struct {

	// address to dial to, if not provided uses original one
	DialAddress *string `protobuf:"bytes,1,opt,name=dialAddress,proto3,oneof" json:"dialAddress,omitempty"`
	// contains filtered or unexported fields
}

func (*DialConfig) Descriptor deprecated added in v1.39.0

func (*DialConfig) Descriptor() ([]byte, []int)

Deprecated: Use DialConfig.ProtoReflect.Descriptor instead.

func (*DialConfig) GetDialAddress added in v1.39.0

func (x *DialConfig) GetDialAddress() string

func (*DialConfig) ProtoMessage added in v1.39.0

func (*DialConfig) ProtoMessage()

func (*DialConfig) ProtoReflect added in v1.39.0

func (x *DialConfig) ProtoReflect() protoreflect.Message

func (*DialConfig) Reset added in v1.39.0

func (x *DialConfig) Reset()

func (*DialConfig) String added in v1.39.0

func (x *DialConfig) String() string

type HTTPOverRPCClient

type HTTPOverRPCClient interface {
	// Make an HTTP call to specified host
	Host(ctx context.Context, in *HostHTTPRequest, opts ...grpc.CallOption) (*HTTPReply, error)
}

HTTPOverRPCClient is the client API for HTTPOverRPC service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

The HTTPOverRPC service definition

type HTTPOverRPCClientProxy

type HTTPOverRPCClientProxy interface {
	HTTPOverRPCClient
	HostOneMany(ctx context.Context, in *HostHTTPRequest, opts ...grpc.CallOption) (<-chan *HostManyResponse, error)
}

HTTPOverRPCClientProxy is the superset of HTTPOverRPCClient which additionally includes the OneMany proxy methods

func NewHTTPOverRPCClientProxy

func NewHTTPOverRPCClientProxy(cc *proxy.Conn) HTTPOverRPCClientProxy

NewHTTPOverRPCClientProxy creates a HTTPOverRPCClientProxy for use in proxied connections. NOTE: This takes a proxy.Conn instead of a generic ClientConnInterface as the methods here are only valid in proxy.Conn contexts.

type HTTPOverRPCServer

type HTTPOverRPCServer interface {
	// Make an HTTP call to specified host
	Host(context.Context, *HostHTTPRequest) (*HTTPReply, error)
}

HTTPOverRPCServer is the server API for HTTPOverRPC service. All implementations should embed UnimplementedHTTPOverRPCServer for forward compatibility.

The HTTPOverRPC service definition

type HTTPReply

type HTTPReply struct {
	StatusCode int32     `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"`
	Headers    []*Header `protobuf:"bytes,2,rep,name=headers,proto3" json:"headers,omitempty"`
	Body       []byte    `protobuf:"bytes,3,opt,name=body,proto3" json:"body,omitempty"`
	// contains filtered or unexported fields
}

HTTPReply describes the HTTP reply

func (*HTTPReply) Descriptor deprecated

func (*HTTPReply) Descriptor() ([]byte, []int)

Deprecated: Use HTTPReply.ProtoReflect.Descriptor instead.

func (*HTTPReply) GetBody

func (x *HTTPReply) GetBody() []byte

func (*HTTPReply) GetHeaders

func (x *HTTPReply) GetHeaders() []*Header

func (*HTTPReply) GetStatusCode

func (x *HTTPReply) GetStatusCode() int32

func (*HTTPReply) ProtoMessage

func (*HTTPReply) ProtoMessage()

func (*HTTPReply) ProtoReflect

func (x *HTTPReply) ProtoReflect() protoreflect.Message

func (*HTTPReply) Reset

func (x *HTTPReply) Reset()

func (*HTTPReply) String

func (x *HTTPReply) String() string

type HTTPRequest

type HTTPRequest struct {
	Method     string    `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"`
	RequestUri string    `protobuf:"bytes,2,opt,name=request_uri,json=requestUri,proto3" json:"request_uri,omitempty"`
	Headers    []*Header `protobuf:"bytes,3,rep,name=headers,proto3" json:"headers,omitempty"`
	Body       []byte    `protobuf:"bytes,4,opt,name=body,proto3" json:"body,omitempty"`
	// contains filtered or unexported fields
}

HTTPRequest describes the HTTP request

func (*HTTPRequest) Descriptor deprecated

func (*HTTPRequest) Descriptor() ([]byte, []int)

Deprecated: Use HTTPRequest.ProtoReflect.Descriptor instead.

func (*HTTPRequest) GetBody

func (x *HTTPRequest) GetBody() []byte

func (*HTTPRequest) GetHeaders

func (x *HTTPRequest) GetHeaders() []*Header

func (*HTTPRequest) GetMethod

func (x *HTTPRequest) GetMethod() string

func (*HTTPRequest) GetRequestUri

func (x *HTTPRequest) GetRequestUri() string

func (*HTTPRequest) ProtoMessage

func (*HTTPRequest) ProtoMessage()

func (*HTTPRequest) ProtoReflect

func (x *HTTPRequest) ProtoReflect() protoreflect.Message

func (*HTTPRequest) Reset

func (x *HTTPRequest) Reset()

func (*HTTPRequest) String

func (x *HTTPRequest) String() string
type Header struct {
	Key    string   `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	Values []string `protobuf:"bytes,2,rep,name=values,proto3" json:"values,omitempty"`
	// contains filtered or unexported fields
}

func (*Header) Descriptor deprecated

func (*Header) Descriptor() ([]byte, []int)

Deprecated: Use Header.ProtoReflect.Descriptor instead.

func (*Header) GetKey

func (x *Header) GetKey() string

func (*Header) GetValues

func (x *Header) GetValues() []string

func (*Header) ProtoMessage

func (*Header) ProtoMessage()

func (*Header) ProtoReflect

func (x *Header) ProtoReflect() protoreflect.Message

func (*Header) Reset

func (x *Header) Reset()

func (*Header) String

func (x *Header) String() string

type HostHTTPRequest added in v1.23.3

type HostHTTPRequest struct {
	Request *HTTPRequest `protobuf:"bytes,1,opt,name=request,proto3" json:"request,omitempty"`
	// The port to use for the request on the local host.
	Port int32 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"`
	// Hostname can be specified as either an ip address or domain name
	Hostname string `protobuf:"bytes,3,opt,name=hostname,proto3" json:"hostname,omitempty"`
	// Protocols for communication like http and https
	Protocol string `protobuf:"bytes,4,opt,name=protocol,proto3" json:"protocol,omitempty"`
	// TLS Config for the request
	Tlsconfig *TLSConfig `protobuf:"bytes,5,opt,name=tlsconfig,proto3" json:"tlsconfig,omitempty"`
	// Dial Config for request, if not provided uses default dialer configuration
	Dialconfig *DialConfig `protobuf:"bytes,6,opt,name=dialconfig,proto3,oneof" json:"dialconfig,omitempty"`
	// contains filtered or unexported fields
}

func (*HostHTTPRequest) Descriptor deprecated added in v1.23.3

func (*HostHTTPRequest) Descriptor() ([]byte, []int)

Deprecated: Use HostHTTPRequest.ProtoReflect.Descriptor instead.

func (*HostHTTPRequest) GetDialconfig added in v1.39.0

func (x *HostHTTPRequest) GetDialconfig() *DialConfig

func (*HostHTTPRequest) GetHostname added in v1.23.3

func (x *HostHTTPRequest) GetHostname() string

func (*HostHTTPRequest) GetPort added in v1.23.3

func (x *HostHTTPRequest) GetPort() int32

func (*HostHTTPRequest) GetProtocol added in v1.23.3

func (x *HostHTTPRequest) GetProtocol() string

func (*HostHTTPRequest) GetRequest added in v1.23.3

func (x *HostHTTPRequest) GetRequest() *HTTPRequest

func (*HostHTTPRequest) GetTlsconfig added in v1.24.6

func (x *HostHTTPRequest) GetTlsconfig() *TLSConfig

func (*HostHTTPRequest) ProtoMessage added in v1.23.3

func (*HostHTTPRequest) ProtoMessage()

func (*HostHTTPRequest) ProtoReflect added in v1.23.3

func (x *HostHTTPRequest) ProtoReflect() protoreflect.Message

func (*HostHTTPRequest) Reset added in v1.23.3

func (x *HostHTTPRequest) Reset()

func (*HostHTTPRequest) String added in v1.23.3

func (x *HostHTTPRequest) String() string

type HostManyResponse added in v1.23.3

type HostManyResponse struct {
	Target string
	// As targets can be duplicated this is the index into the slice passed to proxy.Conn.
	Index int
	Resp  *HTTPReply
	Error error
}

HostManyResponse encapsulates a proxy data packet. It includes the target, index, response and possible error returned.

type TLSConfig added in v1.24.6

type TLSConfig struct {

	// insecureSkipVerify disables TLS verification if set to true.
	InsecureSkipVerify bool `protobuf:"varint,1,opt,name=insecureSkipVerify,proto3" json:"insecureSkipVerify,omitempty"`
	// contains filtered or unexported fields
}

func (*TLSConfig) Descriptor deprecated added in v1.24.6

func (*TLSConfig) Descriptor() ([]byte, []int)

Deprecated: Use TLSConfig.ProtoReflect.Descriptor instead.

func (*TLSConfig) GetInsecureSkipVerify added in v1.24.6

func (x *TLSConfig) GetInsecureSkipVerify() bool

func (*TLSConfig) ProtoMessage added in v1.24.6

func (*TLSConfig) ProtoMessage()

func (*TLSConfig) ProtoReflect added in v1.24.6

func (x *TLSConfig) ProtoReflect() protoreflect.Message

func (*TLSConfig) Reset added in v1.24.6

func (x *TLSConfig) Reset()

func (*TLSConfig) String added in v1.24.6

func (x *TLSConfig) String() string

type UnimplementedHTTPOverRPCServer

type UnimplementedHTTPOverRPCServer struct{}

UnimplementedHTTPOverRPCServer should be embedded to have forward compatible implementations.

NOTE: this should be embedded by value instead of pointer to avoid a nil pointer dereference when methods are called.

func (UnimplementedHTTPOverRPCServer) Host added in v1.23.3

type UnsafeHTTPOverRPCServer

type UnsafeHTTPOverRPCServer interface {
	// contains filtered or unexported methods
}

UnsafeHTTPOverRPCServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to HTTPOverRPCServer will result in compilation errors.

Directories

Path Synopsis
Package client provides the client interface for 'httpoverrpc'
Package client provides the client interface for 'httpoverrpc'
Package server implements the sansshell 'httpoverrpc' service.
Package server implements the sansshell 'httpoverrpc' service.

Jump to

Keyboard shortcuts

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