Send explicit exit notification if UDP
Implement --explicit-exit-notify by default. Fixes #29
This commit is contained in:
parent
c6ab3b57db
commit
c93461b153
|
@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Send explicit exit notification if UDP. [#29](https://github.com/keeshux/tunnelkit/issues/29)
|
||||||
|
|
||||||
## 1.5.0 (2019-03-20)
|
## 1.5.0 (2019-03-20)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -128,6 +128,22 @@ class DataPacket {
|
||||||
static let pingString = Data(hex: "2a187bf3641eb4cb07ed2d0a981fc748")
|
static let pingString = Data(hex: "2a187bf3641eb4cb07ed2d0a981fc748")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum OCCPacket: UInt8 {
|
||||||
|
case exit = 0x06
|
||||||
|
|
||||||
|
private static let magicString = Data(hex: "287f346bd4ef7a812d56b8d3afc5459c")
|
||||||
|
|
||||||
|
func serialized(_ info: Any? = nil) -> Data {
|
||||||
|
var data = OCCPacket.magicString
|
||||||
|
data.append(rawValue)
|
||||||
|
switch self {
|
||||||
|
case .exit:
|
||||||
|
break // nothing more
|
||||||
|
}
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
/// :nodoc:
|
||||||
extension PacketCode: CustomStringConvertible {
|
extension PacketCode: CustomStringConvertible {
|
||||||
public var description: String {
|
public var description: String {
|
||||||
|
|
|
@ -1176,6 +1176,11 @@ public class SessionProxy {
|
||||||
|
|
||||||
private func deferStop(_ method: StopMethod, _ error: Error?) {
|
private func deferStop(_ method: StopMethod, _ error: Error?) {
|
||||||
isStopping = true
|
isStopping = true
|
||||||
|
|
||||||
|
// send exit notification if socket is unreliable (normally UDP)
|
||||||
|
if let link = link, !link.isReliable {
|
||||||
|
sendDataPackets([OCCPacket.exit.serialized()])
|
||||||
|
}
|
||||||
|
|
||||||
switch method {
|
switch method {
|
||||||
case .shutdown:
|
case .shutdown:
|
||||||
|
|
Loading…
Reference in New Issue