Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
b4fd612
add iOS Lib
Apr 28, 2017
f9315ea
test target
Apr 28, 2017
2274329
add object bridge
Apr 28, 2017
d9f93d7
oc bridge working , todo change to dispatch timer recv
Apr 28, 2017
8e01cfb
remove CMake cache
Apr 28, 2017
04eb4ca
share shared scheme
Apr 28, 2017
067fba9
clean code
Apr 28, 2017
5fd9496
kcp read change to dispatch source timer
Apr 28, 2017
03f9467
Update README.md
networkextension Apr 28, 2017
9c4e01c
clean code
Apr 28, 2017
7569306
Merge branch 'master' of https://github.com/networkextension/libkcp
Apr 28, 2017
534cb10
kcp tun input Date update ,support large data
May 3, 2017
e2e1526
add crypt for Darwin platform
May 4, 2017
3f7d75b
UDPSession out_wrapper/Update support crypto , todo test crypto and r…
May 4, 2017
8d0462b
todo test
May 8, 2017
dcb7b49
update protocol imp
May 8, 2017
037c27d
kcptun crypto none also add nonce and crc
May 9, 2017
0f057fa
crypto none support
May 9, 2017
fa80fd8
update udp session read from socket
May 9, 2017
58a51d2
update udp recv
May 9, 2017
c26865c
fix crc sum buffer data length bug
May 12, 2017
c968827
fix c str cmp value
May 12, 2017
108c846
fix cpu load to height use while loop
May 12, 2017
641a018
thread recv data
yarshure May 22, 2017
4994931
Merge branch 'xtaci'
May 22, 2017
d775a9a
bug fix
yarshure May 22, 2017
a4aef34
remove personal data
yarshure May 22, 2017
99929cf
Merge branch 'master' of https://github.com/networkextension/libkcp
yarshure May 22, 2017
ea60347
add a write dispatch queue
yarshure May 22, 2017
f717ed5
set target 9.0
yarshure May 23, 2017
09bcd0e
resolve memory issue
yarshure May 24, 2017
1ebd5ef
packet full ,continue read
yarshure May 26, 2017
c938092
disable debug
yarshure May 26, 2017
14c20c8
update recv
yarshure May 27, 2017
3c27be5
turn speed and memory use, because kcp too fast
yarshure May 27, 2017
f78ce88
policy sleep
yarshure May 27, 2017
3987353
update policy
yarshure Jun 1, 2017
b759087
add local ip
yarshure Jun 1, 2017
fb6b5e3
short 3300
yarshure Jun 2, 2017
2757a1f
Merge branch 'master' of https://github.com/networkextension/libkcp
yarshure Jun 2, 2017
22317be
cell data test
yarshure Jun 2, 2017
a87206d
add OSX target
yarshure Jun 2, 2017
273bbb7
add xcscheme file
yarshure Jun 2, 2017
cc9e950
update macOS target
yarshure Jun 2, 2017
7d5ab06
Update README.md
networkextension Jun 21, 2017
ddc6a9c
Update README.md
networkextension Jun 21, 2017
c0cfb12
update crc32 ,copy from darwin kernel
yarshure Aug 3, 2017
138aefc
turning cpu usage
yarshure Aug 4, 2017
48532e3
socket tunnel work now
androidertyuiopkhkhjk Aug 21, 2017
8ef1e5f
update API
yarshure Jan 16, 2018
f059f21
change to block style API
yarshure Jan 16, 2018
7cfd182
change didRecvData to didRecvdata,Swift imported will Good
yarshure Jan 16, 2018
1f3b4b5
fixed session Block 0xaaaaaaaaaaaaaaaa issue
yarshure Feb 8, 2018
4254dbe
add get local port api
yarshure Feb 8, 2018
c27009a
speed up recv data
yarshure Feb 9, 2018
bef4a86
when send suspend recv queue
yarshure Feb 9, 2018
ee86ccf
Under iOS12 or macOS 10.14 change to use Network.framework event base…
yarshure Oct 18, 2018
b48bf9f
nw after first read ,then crash
yarshure Oct 22, 2018
a555240
fix nw_content_context_t release issue
Oct 29, 2018
db85768
nw base socket work now
Jan 8, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ FEC enhanced KCP client session library for iOS/Android, compatible with [kcp-go
1. Optimized for ***Online Games***.
1. Stream based interface, you can easily switch from your TCP based protocol to libkcp or dualstack.
1. [FEC(Forward Error Correction)](https://en.wikipedia.org/wiki/Forward_error_correction) Support with [Reed-Solomon Codes](https://en.wikipedia.org/wiki/Reed%E2%80%93Solomon_error_correction)

1. Add iOS/macOs Framework and Test target
1. MAS app https://itunes.apple.com/us/app/a-big-t/id1114040100?l=zh&ls=1&mt=12 support kcptun use this lib
## ***Usage***
libkcp has been designed as a ***Frame-Driven*** library, the main loop was supposed as:
```
Expand Down Expand Up @@ -42,7 +43,7 @@ $go run kcpserver.go
compile and run libkcp(Best with CLion), and watch output.

## ***Caveats***
1. Packet level encryption has not been implemented yet.
1. Packet level encryption use CommonCrypto, dose not pass test,need test and debug

## ***Troubleshooting***
1. C++11 is required for compiling.
4 changes: 2 additions & 2 deletions fec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ FEC::Decode(byte *data, size_t sz) {
void
FEC::MarkData(byte *data, uint16_t sz) {
data = encode32u(data,this->next);
data = encode16u(data,typeData);
data = encode16u(data,kcptypeData);
encode16u(data,static_cast<uint16_t>(sz + 2)); // including size itself
this->next++;
}
Expand Down Expand Up @@ -125,7 +125,7 @@ FEC::Input(fecPacket &pkt) {
shardVec[seqid%totalShards] = rx[i].data;
shardflag[seqid%totalShards] = true;
numshard++;
if (rx[i].flag == typeData) {
if (rx[i].flag == kcptypeData) {
numDataShard++;
}
if (numshard == 1) {
Expand Down
3 changes: 2 additions & 1 deletion fec.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
#include "reedsolomon.h"

const size_t fecHeaderSize = 6;
//const size_t cryptHeaderSize = 20;//nonce 16 crc 4
const size_t fecHeaderSizePlus2{fecHeaderSize + 2};
const uint16_t typeData = 0xf1;
const uint16_t kcptypeData = 0xf1;
const uint16_t typeFEC = 0xf2;
const int fecExpire = 30000;

Expand Down
26 changes: 26 additions & 0 deletions iOSLib/libkcp/kcpOSX/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?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>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2017 Kong XiangBo. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
21 changes: 21 additions & 0 deletions iOSLib/libkcp/kcpOSX/kcp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// kcpOSX.h
// kcpOSX
//
// Created by 孔祥波 on 02/06/2017.
// Copyright © 2017 Kong XiangBo. All rights reserved.
//

#import <Cocoa/Cocoa.h>

//! Project version number for kcpOSX.
FOUNDATION_EXPORT double kcpOSXVersionNumber;

//! Project version string for kcpOSX.
FOUNDATION_EXPORT const unsigned char kcpOSXVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <kcpOSX/PublicHeader.h>


#import <kcp/Tunconfig.h>
#import <kcp/SFKcptun.h>
17 changes: 17 additions & 0 deletions iOSLib/libkcp/kcptest/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// AppDelegate.h
// kcptest
//
// Created by 孔祥波 on 28/04/2017.
// Copyright © 2017 Kong XiangBo. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;


@end

51 changes: 51 additions & 0 deletions iOSLib/libkcp/kcptest/AppDelegate.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// AppDelegate.m
// kcptest
//
// Created by 孔祥波 on 28/04/2017.
// Copyright © 2017 Kong XiangBo. All rights reserved.
//

#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
return YES;
}


- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}


- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}


- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
27 changes: 27 additions & 0 deletions iOSLib/libkcp/kcptest/Base.lproj/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
Loading