8 changed files with 0 additions and 526 deletions
@ -1,9 +0,0 @@
|
||||
## Example usage of libzt in Swift app via native static library |
||||
*** |
||||
|
||||
If any of the below instructions seem unclear see [HOWTO: Use a C++ Library from Swift](http://www.swiftprogrammer.info/swift_call_cpp.html) or drop us a message. |
||||
|
||||
- Build (`make static_lib`) or Download: [libzt.a]() |
||||
- Add `libztWrapper.cpp` and `libztWrapper.hpp` and `libztWrapper.swift` to your project |
||||
- Add `include/` (from the cloned libzt repo) to your projects `Header Search Path` |
||||
- Build |
||||
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* ZeroTier SDK - Network Virtualization Everywhere |
||||
* Copyright (C) 2011-2017 ZeroTier, Inc. https://www.zerotier.com/
|
||||
* |
||||
* This program is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* |
||||
* -- |
||||
* |
||||
* You can be released from the requirements of the license by purchasing |
||||
* a commercial license. Buying such a license is mandatory as soon as you |
||||
* develop commercial closed-source software that incorporates or links |
||||
* directly against ZeroTier software without disclosing the source code |
||||
* of your own application. |
||||
*/ |
||||
|
||||
#ifndef LIBZT_BRIDGING_HEADER_H |
||||
#define LIBZT_BRIDGING_HEADER_H |
||||
|
||||
#include <sys/socket.h> |
||||
#include "Defs.h" |
||||
|
||||
// ZT SERVICE CONTROLS (documented in include/libzt.h)
|
||||
void zts_start(const char *path); |
||||
void zts_startjoin(const char *path, const char *nwid); |
||||
void zts_stop(); |
||||
int zts_running(); |
||||
void zts_join(const char *nwid); |
||||
void zts_leave(const char *nwid); |
||||
|
||||
// SOCKET API (documented in include/libzt.h)
|
||||
int zts_connect(ZT_CONNECT_SIG); |
||||
int zts_bind(ZT_BIND_SIG); |
||||
int zts_accept(ZT_ACCEPT_SIG); |
||||
int zts_listen(ZT_LISTEN_SIG); |
||||
int zts_socket(ZT_SOCKET_SIG); |
||||
int zts_setsockopt(ZT_SETSOCKOPT_SIG); |
||||
int zts_getsockopt(ZT_GETSOCKOPT_SIG); |
||||
int zts_close(ZT_CLOSE_SIG); |
||||
int zts_getsockname(ZT_GETSOCKNAME_SIG); |
||||
int zts_getpeername(ZT_GETPEERNAME_SIG); |
||||
int zts_recvfrom(ZT_RECVFROM_SIG); |
||||
int zts_fcntl(ZT_FCNTL_SIG); |
||||
int zts_sendto(ZT_SENDTO_SIG); |
||||
|
||||
#endif /* LIBZT_BRIDGING_HEADER_H */ |
||||
|
||||
|
||||
|
||||
|
||||
@ -1,321 +0,0 @@
|
||||
// !$*UTF8*$! |
||||
{ |
||||
archiveVersion = 1; |
||||
classes = { |
||||
}; |
||||
objectVersion = 48; |
||||
objects = { |
||||
|
||||
/* Begin PBXBuildFile section */ |
||||
7C6AD8CB1F99638D00389F90 /* libzt.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7C6AD8CA1F99638D00389F90 /* libzt.a */; }; |
||||
7C98EF041F99599300454B62 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C98EF031F99599300454B62 /* main.swift */; }; |
||||
7C98EF101F995A9200454B62 /* libztWrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C98EF0E1F995A9200454B62 /* libztWrapper.cpp */; }; |
||||
/* End PBXBuildFile section */ |
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */ |
||||
7C98EEFE1F99599300454B62 /* CopyFiles */ = { |
||||
isa = PBXCopyFilesBuildPhase; |
||||
buildActionMask = 2147483647; |
||||
dstPath = /usr/share/man/man1/; |
||||
dstSubfolderSpec = 0; |
||||
files = ( |
||||
); |
||||
runOnlyForDeploymentPostprocessing = 1; |
||||
}; |
||||
/* End PBXCopyFilesBuildPhase section */ |
||||
|
||||
/* Begin PBXFileReference section */ |
||||
7C6AD8CA1F99638D00389F90 /* libzt.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libzt.a; path = ../../../../build/darwin/libzt.a; sourceTree = "<group>"; }; |
||||
7C98EF001F99599300454B62 /* libztExampleApp */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = libztExampleApp; sourceTree = BUILT_PRODUCTS_DIR; }; |
||||
7C98EF031F99599300454B62 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; }; |
||||
7C98EF0B1F9959F500454B62 /* libzt.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libzt.a; path = ../../../build/darwin/libzt.a; sourceTree = "<group>"; }; |
||||
7C98EF0D1F995A9200454B62 /* libztExampleApp-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "libztExampleApp-Bridging-Header.h"; sourceTree = "<group>"; }; |
||||
7C98EF0E1F995A9200454B62 /* libztWrapper.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = libztWrapper.cpp; sourceTree = "<group>"; }; |
||||
7C98EF0F1F995A9200454B62 /* libztWrapper.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = libztWrapper.hpp; sourceTree = "<group>"; }; |
||||
/* End PBXFileReference section */ |
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */ |
||||
7C98EEFD1F99599300454B62 /* Frameworks */ = { |
||||
isa = PBXFrameworksBuildPhase; |
||||
buildActionMask = 2147483647; |
||||
files = ( |
||||
7C6AD8CB1F99638D00389F90 /* libzt.a in Frameworks */, |
||||
); |
||||
runOnlyForDeploymentPostprocessing = 0; |
||||
}; |
||||
/* End PBXFrameworksBuildPhase section */ |
||||
|
||||
/* Begin PBXGroup section */ |
||||
7C98EEF71F99599300454B62 = { |
||||
isa = PBXGroup; |
||||
children = ( |
||||
7C98EF0E1F995A9200454B62 /* libztWrapper.cpp */, |
||||
7C98EF0F1F995A9200454B62 /* libztWrapper.hpp */, |
||||
7C98EF021F99599300454B62 /* libztExampleApp */, |
||||
7C98EF011F99599300454B62 /* Products */, |
||||
7C98EF0A1F9959F500454B62 /* Frameworks */, |
||||
7C98EF0D1F995A9200454B62 /* libztExampleApp-Bridging-Header.h */, |
||||
); |
||||
sourceTree = "<group>"; |
||||
}; |
||||
7C98EF011F99599300454B62 /* Products */ = { |
||||
isa = PBXGroup; |
||||
children = ( |
||||
7C98EF001F99599300454B62 /* libztExampleApp */, |
||||
); |
||||
name = Products; |
||||
sourceTree = "<group>"; |
||||
}; |
||||
7C98EF021F99599300454B62 /* libztExampleApp */ = { |
||||
isa = PBXGroup; |
||||
children = ( |
||||
7C98EF031F99599300454B62 /* main.swift */, |
||||
); |
||||
path = libztExampleApp; |
||||
sourceTree = "<group>"; |
||||
}; |
||||
7C98EF0A1F9959F500454B62 /* Frameworks */ = { |
||||
isa = PBXGroup; |
||||
children = ( |
||||
7C6AD8CA1F99638D00389F90 /* libzt.a */, |
||||
7C98EF0B1F9959F500454B62 /* libzt.a */, |
||||
); |
||||
name = Frameworks; |
||||
sourceTree = "<group>"; |
||||
}; |
||||
/* End PBXGroup section */ |
||||
|
||||
/* Begin PBXNativeTarget section */ |
||||
7C98EEFF1F99599300454B62 /* libztExampleApp */ = { |
||||
isa = PBXNativeTarget; |
||||
buildConfigurationList = 7C98EF071F99599300454B62 /* Build configuration list for PBXNativeTarget "libztExampleApp" */; |
||||
buildPhases = ( |
||||
7C98EEFC1F99599300454B62 /* Sources */, |
||||
7C98EEFD1F99599300454B62 /* Frameworks */, |
||||
7C98EEFE1F99599300454B62 /* CopyFiles */, |
||||
); |
||||
buildRules = ( |
||||
); |
||||
dependencies = ( |
||||
); |
||||
name = libztExampleApp; |
||||
productName = libztExampleApp; |
||||
productReference = 7C98EF001F99599300454B62 /* libztExampleApp */; |
||||
productType = "com.apple.product-type.tool"; |
||||
}; |
||||
/* End PBXNativeTarget section */ |
||||
|
||||
/* Begin PBXProject section */ |
||||
7C98EEF81F99599300454B62 /* Project object */ = { |
||||
isa = PBXProject; |
||||
attributes = { |
||||
LastSwiftUpdateCheck = 0900; |
||||
LastUpgradeCheck = 0900; |
||||
ORGANIZATIONNAME = "ZeroTier, Inc."; |
||||
TargetAttributes = { |
||||
7C98EEFF1F99599300454B62 = { |
||||
CreatedOnToolsVersion = 9.0; |
||||
LastSwiftMigration = 0900; |
||||
ProvisioningStyle = Automatic; |
||||
}; |
||||
}; |
||||
}; |
||||
buildConfigurationList = 7C98EEFB1F99599300454B62 /* Build configuration list for PBXProject "libztExampleApp" */; |
||||
compatibilityVersion = "Xcode 8.0"; |
||||
developmentRegion = en; |
||||
hasScannedForEncodings = 0; |
||||
knownRegions = ( |
||||
en, |
||||
); |
||||
mainGroup = 7C98EEF71F99599300454B62; |
||||
productRefGroup = 7C98EF011F99599300454B62 /* Products */; |
||||
projectDirPath = ""; |
||||
projectRoot = ""; |
||||
targets = ( |
||||
7C98EEFF1F99599300454B62 /* libztExampleApp */, |
||||
); |
||||
}; |
||||
/* End PBXProject section */ |
||||
|
||||
/* Begin PBXSourcesBuildPhase section */ |
||||
7C98EEFC1F99599300454B62 /* Sources */ = { |
||||
isa = PBXSourcesBuildPhase; |
||||
buildActionMask = 2147483647; |
||||
files = ( |
||||
7C98EF041F99599300454B62 /* main.swift in Sources */, |
||||
7C98EF101F995A9200454B62 /* libztWrapper.cpp in Sources */, |
||||
); |
||||
runOnlyForDeploymentPostprocessing = 0; |
||||
}; |
||||
/* End PBXSourcesBuildPhase section */ |
||||
|
||||
/* Begin XCBuildConfiguration section */ |
||||
7C98EF051F99599300454B62 /* Debug */ = { |
||||
isa = XCBuildConfiguration; |
||||
buildSettings = { |
||||
ALWAYS_SEARCH_USER_PATHS = NO; |
||||
CLANG_ANALYZER_NONNULL = YES; |
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; |
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; |
||||
CLANG_CXX_LIBRARY = "libc++"; |
||||
CLANG_ENABLE_MODULES = YES; |
||||
CLANG_ENABLE_OBJC_ARC = YES; |
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; |
||||
CLANG_WARN_BOOL_CONVERSION = YES; |
||||
CLANG_WARN_COMMA = YES; |
||||
CLANG_WARN_CONSTANT_CONVERSION = YES; |
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; |
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES; |
||||
CLANG_WARN_EMPTY_BODY = YES; |
||||
CLANG_WARN_ENUM_CONVERSION = YES; |
||||
CLANG_WARN_INFINITE_RECURSION = YES; |
||||
CLANG_WARN_INT_CONVERSION = YES; |
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; |
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; |
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; |
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; |
||||
CLANG_WARN_STRICT_PROTOTYPES = YES; |
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES; |
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; |
||||
CLANG_WARN_UNREACHABLE_CODE = YES; |
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; |
||||
CODE_SIGN_IDENTITY = "-"; |
||||
COPY_PHASE_STRIP = NO; |
||||
DEBUG_INFORMATION_FORMAT = dwarf; |
||||
ENABLE_STRICT_OBJC_MSGSEND = YES; |
||||
ENABLE_TESTABILITY = YES; |
||||
GCC_C_LANGUAGE_STANDARD = gnu11; |
||||
GCC_DYNAMIC_NO_PIC = NO; |
||||
GCC_NO_COMMON_BLOCKS = YES; |
||||
GCC_OPTIMIZATION_LEVEL = 0; |
||||
GCC_PREPROCESSOR_DEFINITIONS = ( |
||||
"DEBUG=1", |
||||
"$(inherited)", |
||||
); |
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES; |
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; |
||||
GCC_WARN_UNDECLARED_SELECTOR = YES; |
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; |
||||
GCC_WARN_UNUSED_FUNCTION = YES; |
||||
GCC_WARN_UNUSED_VARIABLE = YES; |
||||
MACOSX_DEPLOYMENT_TARGET = 10.12; |
||||
MTL_ENABLE_DEBUG_INFO = YES; |
||||
ONLY_ACTIVE_ARCH = YES; |
||||
SDKROOT = macosx; |
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; |
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; |
||||
}; |
||||
name = Debug; |
||||
}; |
||||
7C98EF061F99599300454B62 /* Release */ = { |
||||
isa = XCBuildConfiguration; |
||||
buildSettings = { |
||||
ALWAYS_SEARCH_USER_PATHS = NO; |
||||
CLANG_ANALYZER_NONNULL = YES; |
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; |
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; |
||||
CLANG_CXX_LIBRARY = "libc++"; |
||||
CLANG_ENABLE_MODULES = YES; |
||||
CLANG_ENABLE_OBJC_ARC = YES; |
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; |
||||
CLANG_WARN_BOOL_CONVERSION = YES; |
||||
CLANG_WARN_COMMA = YES; |
||||
CLANG_WARN_CONSTANT_CONVERSION = YES; |
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; |
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES; |
||||
CLANG_WARN_EMPTY_BODY = YES; |
||||
CLANG_WARN_ENUM_CONVERSION = YES; |
||||
CLANG_WARN_INFINITE_RECURSION = YES; |
||||
CLANG_WARN_INT_CONVERSION = YES; |
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; |
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; |
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; |
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; |
||||
CLANG_WARN_STRICT_PROTOTYPES = YES; |
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES; |
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; |
||||
CLANG_WARN_UNREACHABLE_CODE = YES; |
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; |
||||
CODE_SIGN_IDENTITY = "-"; |
||||
COPY_PHASE_STRIP = NO; |
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; |
||||
ENABLE_NS_ASSERTIONS = NO; |
||||
ENABLE_STRICT_OBJC_MSGSEND = YES; |
||||
GCC_C_LANGUAGE_STANDARD = gnu11; |
||||
GCC_NO_COMMON_BLOCKS = YES; |
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES; |
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; |
||||
GCC_WARN_UNDECLARED_SELECTOR = YES; |
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; |
||||
GCC_WARN_UNUSED_FUNCTION = YES; |
||||
GCC_WARN_UNUSED_VARIABLE = YES; |
||||
MACOSX_DEPLOYMENT_TARGET = 10.12; |
||||
MTL_ENABLE_DEBUG_INFO = NO; |
||||
SDKROOT = macosx; |
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; |
||||
}; |
||||
name = Release; |
||||
}; |
||||
7C98EF081F99599300454B62 /* Debug */ = { |
||||
isa = XCBuildConfiguration; |
||||
buildSettings = { |
||||
CLANG_ENABLE_MODULES = YES; |
||||
CODE_SIGN_STYLE = Automatic; |
||||
HEADER_SEARCH_PATHS = ../../../../include; |
||||
"HEADER_SEARCH_PATHS[arch=*]" = ""; |
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; |
||||
LIBRARY_SEARCH_PATHS = ( |
||||
../../../../build/darwin, |
||||
"$(PROJECT_DIR)", |
||||
); |
||||
PRODUCT_NAME = "$(TARGET_NAME)"; |
||||
SWIFT_OBJC_BRIDGING_HEADER = "libztExampleApp-Bridging-Header.h"; |
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; |
||||
SWIFT_VERSION = 4.0; |
||||
USER_HEADER_SEARCH_PATHS = "../../../../include $(PROJECT_DIR)"; |
||||
}; |
||||
name = Debug; |
||||
}; |
||||
7C98EF091F99599300454B62 /* Release */ = { |
||||
isa = XCBuildConfiguration; |
||||
buildSettings = { |
||||
CLANG_ENABLE_MODULES = YES; |
||||
CODE_SIGN_STYLE = Automatic; |
||||
HEADER_SEARCH_PATHS = ../../../../include; |
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; |
||||
LIBRARY_SEARCH_PATHS = ( |
||||
../../../../build/darwin, |
||||
"$(PROJECT_DIR)", |
||||
); |
||||
PRODUCT_NAME = "$(TARGET_NAME)"; |
||||
SWIFT_OBJC_BRIDGING_HEADER = "libztExampleApp-Bridging-Header.h"; |
||||
SWIFT_VERSION = 4.0; |
||||
USER_HEADER_SEARCH_PATHS = "../../../../include $(PROJECT_DIR)"; |
||||
}; |
||||
name = Release; |
||||
}; |
||||
/* End XCBuildConfiguration section */ |
||||
|
||||
/* Begin XCConfigurationList section */ |
||||
7C98EEFB1F99599300454B62 /* Build configuration list for PBXProject "libztExampleApp" */ = { |
||||
isa = XCConfigurationList; |
||||
buildConfigurations = ( |
||||
7C98EF051F99599300454B62 /* Debug */, |
||||
7C98EF061F99599300454B62 /* Release */, |
||||
); |
||||
defaultConfigurationIsVisible = 0; |
||||
defaultConfigurationName = Release; |
||||
}; |
||||
7C98EF071F99599300454B62 /* Build configuration list for PBXNativeTarget "libztExampleApp" */ = { |
||||
isa = XCConfigurationList; |
||||
buildConfigurations = ( |
||||
7C98EF081F99599300454B62 /* Debug */, |
||||
7C98EF091F99599300454B62 /* Release */, |
||||
); |
||||
defaultConfigurationIsVisible = 0; |
||||
defaultConfigurationName = Release; |
||||
}; |
||||
/* End XCConfigurationList section */ |
||||
}; |
||||
rootObject = 7C98EEF81F99599300454B62 /* Project object */; |
||||
} |
||||
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<Workspace |
||||
version = "1.0"> |
||||
<FileRef |
||||
location = "self:libztExampleApp.xcodeproj"> |
||||
</FileRef> |
||||
</Workspace> |
||||
@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
||||
<plist version="1.0"> |
||||
<dict> |
||||
<key>SchemeUserState</key> |
||||
<dict> |
||||
<key>libztExampleApp.xcscheme</key> |
||||
<dict> |
||||
<key>orderHint</key> |
||||
<integer>0</integer> |
||||
</dict> |
||||
</dict> |
||||
</dict> |
||||
</plist> |
||||
@ -1,46 +0,0 @@
|
||||
// |
||||
// main.swift |
||||
// libztExampleApp |
||||
// |
||||
// Created by Joseph Henry on 10/19/17. |
||||
// Copyright © 2017 ZeroTier, Inc. All rights reserved. |
||||
// |
||||
|
||||
print("starting libzt...") |
||||
zts_startjoin("xcode_libzt_path", "XXXXXXXXXXXXXXXX") |
||||
print("libzt is online.") |
||||
|
||||
// create address structure |
||||
var addr_str = "0.0.0.0" |
||||
var port = 8080 |
||||
var in4 = sockaddr_in(sin_len: UInt8(MemoryLayout<sockaddr_in>.size), |
||||
sin_family: UInt8(AF_INET), |
||||
sin_port: UInt16(port).bigEndian, |
||||
sin_addr: in_addr(s_addr: 0), |
||||
sin_zero: (0,0,0,0,0,0,0,0)) |
||||
inet_pton(AF_INET, addr_str, &(in4.sin_addr)); |
||||
|
||||
// socket() |
||||
var fd = zts_socket(2, 1, 0) |
||||
|
||||
// bind() |
||||
var addrlen = socklen_t(MemoryLayout.size(ofValue: in4)) |
||||
let a = withUnsafeMutablePointer(to: &in4) { |
||||
$0.withMemoryRebound(to: sockaddr.self, capacity: 1) { |
||||
zts_bind(fd, $0, addrlen) |
||||
} |
||||
} |
||||
|
||||
// listen() |
||||
zts_listen(fd, 1) |
||||
|
||||
// accept |
||||
var clientAddress: sockaddr_in? |
||||
|
||||
addrlen = socklen_t(MemoryLayout.size(ofValue: clientAddress)) |
||||
let b = withUnsafeMutablePointer(to: &clientAddress) { |
||||
$0.withMemoryRebound(to: sockaddr.self, capacity: 1) { |
||||
zts_accept(fd, UnsafeMutablePointer<sockaddr>($0), UnsafeMutablePointer<socklen_t>(&addrlen)) |
||||
} |
||||
} |
||||
|
||||
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* ZeroTier SDK - Network Virtualization Everywhere |
||||
* Copyright (C) 2011-2017 ZeroTier, Inc. https://www.zerotier.com/
|
||||
* |
||||
* This program is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* |
||||
* -- |
||||
* |
||||
* You can be released from the requirements of the license by purchasing |
||||
* a commercial license. Buying such a license is mandatory as soon as you |
||||
* develop commercial closed-source software that incorporates or links |
||||
* directly against ZeroTier software without disclosing the source code |
||||
* of your own application. |
||||
*/ |
||||
|
||||
#include "libzt.h" |
||||
#include "libztWrapper.hpp" |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
// Nothing, implementation is in src/libzt.cpp
|
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
@ -1,31 +0,0 @@
|
||||
/*
|
||||
* ZeroTier SDK - Network Virtualization Everywhere |
||||
* Copyright (C) 2011-2017 ZeroTier, Inc. https://www.zerotier.com/
|
||||
* |
||||
* This program is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* |
||||
* -- |
||||
* |
||||
* You can be released from the requirements of the license by purchasing |
||||
* a commercial license. Buying such a license is mandatory as soon as you |
||||
* develop commercial closed-source software that incorporates or links |
||||
* directly against ZeroTier software without disclosing the source code |
||||
* of your own application. |
||||
*/ |
||||
|
||||
#ifndef LIBZT_XCODE_WRAPPER_HPP |
||||
#define LIBZT_XCODE_WRAPPER_HPP |
||||
|
||||
#endif // LIBZT_XCODE_WRAPPER_HPP
|
||||
|
||||
Loading…
Reference in new issue