Skip to content

Commit e2d7b28

Browse files
committed
Move npipe config to its own section
1 parent 5f860db commit e2d7b28

4 files changed

Lines changed: 39 additions & 17 deletions

File tree

config/confignet/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ leverage network configuration to set connection and transport information.
1616
"npipe" (Windows named pipes, Windows-only).
1717
- `dialer`: Dialer configuration
1818
- `timeout`: Dialer timeout is the maximum amount of time a dial will wait for a connect to complete. The default is no timeout.
19+
- `npipe`: Windows named pipe configuration (ignored for all other transport types)
1920
- `security_descriptor`: A [Security Descriptor Definition Language (SDDL)](https://learn.microsoft.com/en-us/windows/win32/secauthz/security-descriptor-definition-language)
20-
string applied when creating a Windows named pipe listener. Ignored for any
21-
transport other than `npipe` and for client-side dials. When empty, Windows
22-
applies its [default named pipe DACL](https://learn.microsoft.com/en-us/windows/win32/ipc/named-pipe-security-and-access-rights),
21+
string applied to the named pipe when a listener is created. When empty,
22+
Windows applies its [default named pipe DACL](https://learn.microsoft.com/en-us/windows/win32/ipc/named-pipe-security-and-access-rights),
2323
which is roughly equivalent to
2424
`D:P(A;;GA;;;SY)(A;;GA;;;BA)(A;;0x12019b;;;WD)(A;;0x12019b;;;AN)` — full
2525
control for `LocalSystem` (`SY`) and `Administrators` (`BA`), and read plus

config/confignet/config.schema.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ $defs:
66
dialer:
77
description: DialerConfig contains options for connecting to an address.
88
$ref: dialer_config
9+
npipe:
10+
description: NpipeConfig contains options specific to the "npipe" transport (Windows named pipes). Settings in this section are ignored for all other transport types.
11+
$ref: npipe_config
912
endpoint:
1013
description: Endpoint configures the address for this network connection. For TCP and UDP networks, the address has the form "host:port". The host must be a literal IP address, or a host name that can be resolved to IP addresses. The port must be a literal port number or a service name. If the host is a literal IPv6 address it must be enclosed in square brackets, as in "[2001:db8::1]:80" or "[fe80::1%zone]:80". The zone specifies the scope of the literal IPv6 address as defined in RFC 4007.
1114
type: string
@@ -16,14 +19,18 @@ $defs:
1619
description: DialerConfig contains options for connecting to an address.
1720
type: object
1821
properties:
19-
security_descriptor:
20-
description: SecurityDescriptor is a Security Descriptor Definition Language (SDDL) string used when creating a Windows named pipe listener. It is ignored for any transport other than "npipe" and for client-side dials. When empty, Windows applies its default named pipe DACL, which is roughly equivalent to "D:P(A;;GA;;;SY)(A;;GA;;;BA)(A;;0x12019b;;;WD)(A;;0x12019b;;;AN)" — full control for LocalSystem (SY) and Administrators (BA), and read plus limited write for Everyone (WD) and Anonymous Logon (AN). See https://learn.microsoft.com/en-us/windows/win32/ipc/named-pipe-security-and-access-rights and https://learn.microsoft.com/en-us/windows/win32/secauthz/security-descriptor-definition-language
21-
type: string
2222
timeout:
2323
description: Timeout is the maximum amount of time a dial will wait for a connect to complete. The default is no timeout.
2424
type: string
2525
x-customType: time.Duration
2626
format: duration
27+
npipe_config:
28+
description: NpipeConfig contains options specific to Windows named pipe transport. Settings in this section are ignored for all other transport types.
29+
type: object
30+
properties:
31+
security_descriptor:
32+
description: SecurityDescriptor is a Security Descriptor Definition Language (SDDL) string applied to the named pipe when a listener is created. When empty, Windows applies its default named pipe DACL, which is roughly equivalent to "D:P(A;;GA;;;SY)(A;;GA;;;BA)(A;;0x12019b;;;WD)(A;;0x12019b;;;AN)" — full control for LocalSystem (SY) and Administrators (BA), and read plus limited write for Everyone (WD) and Anonymous Logon (AN). See https://learn.microsoft.com/en-us/windows/win32/ipc/named-pipe-security-and-access-rights and https://learn.microsoft.com/en-us/windows/win32/secauthz/security-descriptor-definition-language
33+
type: string
2734
tcp_addr_config:
2835
description: TCPAddrConfig represents a TCP endpoint address.
2936
type: object

config/confignet/confignet.go

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,23 @@ type DialerConfig struct {
6363
// Timeout is the maximum amount of time a dial will wait for
6464
// a connect to complete. The default is no timeout.
6565
Timeout time.Duration `mapstructure:"timeout,omitempty"`
66+
// prevent unkeyed literal initialization
67+
_ struct{}
68+
}
69+
70+
// NewDefaultDialerConfig creates a new DialerConfig with any default values set
71+
func NewDefaultDialerConfig() DialerConfig {
72+
return DialerConfig{}
73+
}
74+
75+
// NpipeConfig contains options specific to Windows named pipe transport.
76+
type NpipeConfig struct {
6677
// SecurityDescriptor is a Security Descriptor Definition Language (SDDL)
67-
// string used when creating a Windows named pipe listener. It is ignored
68-
// for any transport other than "npipe" and for client-side dials. When
69-
// empty, Windows applies its default named pipe DACL, which is roughly
70-
// equivalent to "D:P(A;;GA;;;SY)(A;;GA;;;BA)(A;;0x12019b;;;WD)(A;;0x12019b;;;AN)"
71-
// — full control for LocalSystem (SY) and Administrators (BA), and
72-
// read plus limited write for Everyone (WD) and Anonymous Logon (AN).
78+
// string applied to the named pipe when a listener is created. When empty,
79+
// Windows applies its default named pipe DACL, which is roughly equivalent
80+
// to "D:P(A;;GA;;;SY)(A;;GA;;;BA)(A;;0x12019b;;;WD)(A;;0x12019b;;;AN)"
81+
// — full control for LocalSystem (SY) and Administrators (BA), and read
82+
// plus limited write for Everyone (WD) and Anonymous Logon (AN).
7383
// See:
7484
// - https://learn.microsoft.com/en-us/windows/win32/ipc/named-pipe-security-and-access-rights
7585
// - https://learn.microsoft.com/en-us/windows/win32/secauthz/security-descriptor-definition-language
@@ -78,9 +88,9 @@ type DialerConfig struct {
7888
_ struct{}
7989
}
8090

81-
// NewDefaultDialerConfig creates a new DialerConfig with any default values set
82-
func NewDefaultDialerConfig() DialerConfig {
83-
return DialerConfig{}
91+
// NewDefaultNpipeConfig creates a new NpipeConfig with any default values set
92+
func NewDefaultNpipeConfig() NpipeConfig {
93+
return NpipeConfig{}
8494
}
8595

8696
// AddrConfig represents a network endpoint address.
@@ -99,6 +109,10 @@ type AddrConfig struct {
99109

100110
// DialerConfig contains options for connecting to an address.
101111
DialerConfig DialerConfig `mapstructure:"dialer,omitempty"`
112+
113+
// NpipeConfig contains options specific to the "npipe" transport (Windows named pipes).
114+
// Settings in this section are ignored for all other transport types.
115+
NpipeConfig NpipeConfig `mapstructure:"npipe,omitempty"`
102116
// prevent unkeyed literal initialization
103117
_ struct{}
104118
}
@@ -107,6 +121,7 @@ type AddrConfig struct {
107121
func NewDefaultAddrConfig() AddrConfig {
108122
return AddrConfig{
109123
DialerConfig: NewDefaultDialerConfig(),
124+
NpipeConfig: NewDefaultNpipeConfig(),
110125
}
111126
}
112127

@@ -122,7 +137,7 @@ func (na *AddrConfig) Dial(ctx context.Context) (net.Conn, error) {
122137
// Listen equivalent with net.ListenConfig's Listen for this address.
123138
func (na *AddrConfig) Listen(ctx context.Context) (net.Listener, error) {
124139
if na.Transport == TransportTypeNpipe {
125-
return listenNpipe(na.Endpoint, na.DialerConfig.SecurityDescriptor)
140+
return listenNpipe(na.Endpoint, na.NpipeConfig.SecurityDescriptor)
126141
}
127142
lc := net.ListenConfig{}
128143
return lc.Listen(ctx, string(na.Transport), na.Endpoint)

config/confignet/npipe_windows_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TestNpipeListenSecurityDescriptor(t *testing.T) {
6868
nas := &AddrConfig{
6969
Endpoint: `\\.\pipe\otel-test-confignet-sd`,
7070
Transport: TransportTypeNpipe,
71-
DialerConfig: DialerConfig{
71+
NpipeConfig: NpipeConfig{
7272
SecurityDescriptor: tt.securityDescriptor,
7373
},
7474
}

0 commit comments

Comments
 (0)