Support for GetSharedServers
This commit is contained in:
parent
53fd96d22e
commit
98bcdd16cf
1 changed files with 13 additions and 2 deletions
15
server.go
15
server.go
|
|
@ -21,7 +21,7 @@ func (c *Client) NewServer() (*Server, error) {
|
|||
return &Server{client: c}, nil
|
||||
}
|
||||
|
||||
type serverSharingResponse struct {
|
||||
type Port struct {
|
||||
SourcePort int `json:"sourcePort"`
|
||||
DestinationPort int `json:"destinationPort"`
|
||||
SessionName string `json:"sessionName"`
|
||||
|
|
@ -36,7 +36,7 @@ type serverSharingResponse struct {
|
|||
func (s *Server) StartSharing(ctx context.Context, protocol string, port int) error {
|
||||
s.port = port
|
||||
|
||||
var response serverSharingResponse
|
||||
var response Port
|
||||
if err := s.client.rpc.do(ctx, "serverSharing.startSharing", []interface{}{
|
||||
port, protocol, fmt.Sprintf("http://localhost:%s", strconv.Itoa(port)),
|
||||
}, &response); err != nil {
|
||||
|
|
@ -48,3 +48,14 @@ func (s *Server) StartSharing(ctx context.Context, protocol string, port int) er
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
type Ports []*Port
|
||||
|
||||
func (s *Server) GetSharedServers(ctx context.Context) (Ports, error) {
|
||||
var response Ports
|
||||
if err := s.client.rpc.do(ctx, "serverSharing.getSharedServers", []string{}, &response); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return response, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue