-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.go
179 lines (165 loc) · 9.09 KB
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
package ieventsystem
import (
"context"
"fmt"
"strings"
"unicode/utf16"
dcerpc "github.com/oiweiwei/go-msrpc/dcerpc"
errors "github.com/oiweiwei/go-msrpc/dcerpc/errors"
uuid "github.com/oiweiwei/go-msrpc/midl/uuid"
idispatch "github.com/oiweiwei/go-msrpc/msrpc/dcom/oaut/idispatch/v0"
ndr "github.com/oiweiwei/go-msrpc/ndr"
)
var (
_ = context.Background
_ = fmt.Errorf
_ = utf16.Encode
_ = strings.TrimPrefix
_ = ndr.ZeroString
_ = (*uuid.UUID)(nil)
_ = (*dcerpc.SyntaxID)(nil)
_ = (*errors.Error)(nil)
_ = idispatch.GoPackage
)
// IEventSystem server interface.
type EventSystemServer interface {
// IDispatch base class.
idispatch.DispatchServer
// The Query method is called by a client to query a collection for a collection of
// event classes or subscriptions.
//
// Return Values: An HRESULT that specifies success or failure. All success codes MUST
// be treated the same, and all failure codes other than EVENT_E_QUERYSYNTAX and EVENT_E_QUERYFIELD
// MUST be treated the same.
//
// +--------------------------------+------------------------------------------------------------------+
// | RETURN | |
// | VALUE/CODE | DESCRIPTION |
// | | |
// +--------------------------------+------------------------------------------------------------------+
// +--------------------------------+------------------------------------------------------------------+
// | 0x80040203 EVENT_E_QUERYSYNTAX | A syntax error occurred while trying to evaluate a query string. |
// +--------------------------------+------------------------------------------------------------------+
// | 0x80040204 EVENT_E_QUERYFIELD | An invalid field name was used in a query string. |
// +--------------------------------+------------------------------------------------------------------+
Query(context.Context, *QueryRequest) (*QueryResponse, error)
// The Store method is called by a client to store either an event class or a subscription.
//
// Return Values: An HRESULT that specifies success or failure. All success codes MUST
// be treated the same, and all failure codes other than EVENT_E_INVALID_PER_USER_SID
// MUST be treated the same.
//
// +-----------------------------------------+----------------------------------------------------------------------------------+
// | RETURN | |
// | VALUE/CODE | DESCRIPTION |
// | | |
// +-----------------------------------------+----------------------------------------------------------------------------------+
// +-----------------------------------------+----------------------------------------------------------------------------------+
// | 0x80040207 EVENT_E_INVALID_PER_USER_SID | The owner SID, as defined in [MS-DTYP] section 2.4.2, on a per-user subscription |
// | | does not exist. |
// +-----------------------------------------+----------------------------------------------------------------------------------+
Store(context.Context, *StoreRequest) (*StoreResponse, error)
// Remove operation.
Remove(context.Context, *RemoveRequest) (*RemoveResponse, error)
// The get_EventObjectChangeEventClassID method extracts the server-specific EventClassID
// for server-specific event class or subscription change notifications.
//
// Return Values: An HRESULT specifying success or failure. All success codes MUST be
// treated the same, and all failure codes MUST be treated the same.
GetEventObjectChangeEventClassID(context.Context, *GetEventObjectChangeEventClassIDRequest) (*GetEventObjectChangeEventClassIDResponse, error)
// The QueryS method is called by the client to query a specific event class or subscription.
//
// Return Values: An HRESULT that specifies success or failure. All success codes MUST
// be treated the same, and all failure codes other than EVENT_E_QUERYSYNTAX and EVENT_E_QUERYFIELD
// MUST be treated the same.
//
// +--------------------------------+------------------------------------------------------------------+
// | RETURN | |
// | VALUE/CODE | DESCRIPTION |
// | | |
// +--------------------------------+------------------------------------------------------------------+
// +--------------------------------+------------------------------------------------------------------+
// | 0x80040203 EVENT_E_QUERYSYNTAX | A syntax error occurred while trying to evaluate a query string. |
// +--------------------------------+------------------------------------------------------------------+
// | 0x80040204 EVENT_E_QUERYFIELD | An invalid field name was used in a query string. |
// +--------------------------------+------------------------------------------------------------------+
QueryS(context.Context, *QuerySRequest) (*QuerySResponse, error)
// The RemoveS method is called by the client to remove an event class or subscription.
//
// Return Values: An HRESULT specifying success or failure. All success codes MUST be
// treated the same, and all failure codes other than EVENT_E_QUERYSYNTAX, EVENT_E_QUERYFIELD,
// and EVENT_E_NOT_ALL_REMOVED MUST be treated the same.
//
// +------------------------------------+------------------------------------------------------------------+
// | RETURN | |
// | VALUE/CODE | DESCRIPTION |
// | | |
// +------------------------------------+------------------------------------------------------------------+
// +------------------------------------+------------------------------------------------------------------+
// | 0x80040203 EVENT_E_QUERYSYNTAX | A syntax error occurred while trying to evaluate a query string. |
// +------------------------------------+------------------------------------------------------------------+
// | 0x80040204 EVENT_E_QUERYFIELD | An invalid field name was used in a query string. |
// +------------------------------------+------------------------------------------------------------------+
// | 0x8004020B EVENT_E_NOT_ALL_REMOVED | Not all of the requested objects could be removed. |
// +------------------------------------+------------------------------------------------------------------+
RemoveS(context.Context, *RemoveSRequest) (*RemoveSResponse, error)
}
func RegisterEventSystemServer(conn dcerpc.Conn, o EventSystemServer, opts ...dcerpc.Option) {
conn.RegisterServer(NewEventSystemServerHandle(o), append(opts, dcerpc.WithAbstractSyntax(EventSystemSyntaxV0_0))...)
}
func NewEventSystemServerHandle(o EventSystemServer) dcerpc.ServerHandle {
return func(ctx context.Context, opNum int, r ndr.Reader) (dcerpc.Operation, error) {
return EventSystemServerHandle(ctx, o, opNum, r)
}
}
func EventSystemServerHandle(ctx context.Context, o EventSystemServer, opNum int, r ndr.Reader) (dcerpc.Operation, error) {
if opNum < 7 {
// IDispatch base method.
return idispatch.DispatchServerHandle(ctx, o, opNum, r)
}
switch opNum {
case 7: // Query
in := &QueryRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.Query(ctx, in)
return resp.xxx_ToOp(ctx), err
case 8: // Store
in := &StoreRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.Store(ctx, in)
return resp.xxx_ToOp(ctx), err
case 9: // Remove
in := &RemoveRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.Remove(ctx, in)
return resp.xxx_ToOp(ctx), err
case 10: // EventObjectChangeEventClassID
in := &GetEventObjectChangeEventClassIDRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.GetEventObjectChangeEventClassID(ctx, in)
return resp.xxx_ToOp(ctx), err
case 11: // QueryS
in := &QuerySRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.QueryS(ctx, in)
return resp.xxx_ToOp(ctx), err
case 12: // RemoveS
in := &RemoveSRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.RemoveS(ctx, in)
return resp.xxx_ToOp(ctx), err
}
return nil, nil
}