-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(aws-ec2): add support for UDP to SecurityGroupRule #835
Changes from 1 commit
f332c82
a4918e7
d072dc4
33ed772
81cd079
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -234,7 +234,92 @@ export class TcpAllPorts implements IPortRange { | |
} | ||
|
||
/** | ||
* All TCP Ports | ||
* A single UDP port | ||
*/ | ||
export class UdpPort implements IPortRange { | ||
public readonly canInlineRule = true; | ||
|
||
constructor(private readonly port: number) { | ||
} | ||
|
||
public toRuleJSON(): any { | ||
return { | ||
ipProtocol: Protocol.Udp, | ||
fromPort: this.port, | ||
toPort: this.port | ||
}; | ||
} | ||
|
||
public toString() { | ||
return `${this.port}`; | ||
} | ||
} | ||
|
||
/** | ||
* A single UDP port that is provided by a resource attribute | ||
*/ | ||
export class UdpPortFromAttribute implements IPortRange { | ||
public readonly canInlineRule = false; | ||
|
||
constructor(private readonly port: string) { | ||
} | ||
|
||
public toRuleJSON(): any { | ||
return { | ||
ipProtocol: Protocol.Udp, | ||
fromPort: this.port, | ||
toPort: this.port | ||
}; | ||
} | ||
|
||
public toString() { | ||
return '{IndirectPort}'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rix0rrr Will this conflict with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it will. |
||
} | ||
} | ||
|
||
/** | ||
* A UDP port range | ||
*/ | ||
export class UdpPortRange implements IPortRange { | ||
public readonly canInlineRule = true; | ||
|
||
constructor(private readonly startPort: number, private readonly endPort: number) { | ||
} | ||
|
||
public toRuleJSON(): any { | ||
return { | ||
ipProtocol: Protocol.Udp, | ||
fromPort: this.startPort, | ||
toPort: this.endPort | ||
}; | ||
} | ||
|
||
public toString() { | ||
return `${this.startPort}-${this.endPort}`; | ||
ChintanRaval marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
||
/** | ||
* All UDP Ports | ||
*/ | ||
export class UdpAllPorts implements IPortRange { | ||
public readonly canInlineRule = true; | ||
|
||
public toRuleJSON(): any { | ||
return { | ||
ipProtocol: Protocol.Udp, | ||
fromPort: 0, | ||
toPort: 65535 | ||
}; | ||
} | ||
|
||
public toString() { | ||
return 'ALL PORTS'; | ||
ChintanRaval marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
||
/** | ||
* All Traffic | ||
*/ | ||
export class AllConnections implements IPortRange { | ||
public readonly canInlineRule = true; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add the word UDP to this description string?
LIke
UDP ${this.port}
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rix0rrr Sure, while I prefix all the UDP-related
toString()
to useUDP
, should I also do the same for the TCP ones? Just for consistency. We'd achieve uniqueness either way, but thought why should one be treated as a first-class citizen over the other?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, is it worth it to do something like
${Protocol.Udp} ${this.port}
as compared toUDP ${this.port}
?