diff --git a/NetworkEye.podspec b/NetworkEye.podspec index 97ab5e2..755080e 100755 --- a/NetworkEye.podspec +++ b/NetworkEye.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| s.name = "NetworkEye" - s.version = "0.9.9" + s.version = "1.0" s.summary = "NetworkEye - a iOS network debug library ,It can monitor HTTP requests within the App and displays information related to the request." s.homepage = "https://github.com/coderyi/NetworkEye" s.license = "MIT" s.authors = { "coderyi" => "coderyi@163.com" } - s.source = { :git => "https://github.com/coderyi/NetworkEye.git", :tag => "0.9.9" } + s.source = { :git => "https://github.com/coderyi/NetworkEye.git", :tag => "1.0" } s.frameworks = 'Foundation', 'CoreGraphics', 'UIKit' s.library = "sqlite3" s.platform = :ios, '7.0' diff --git a/NetworkEye/AppDelegate.m b/NetworkEye/AppDelegate.m index 0aed3a6..aa13f0f 100644 --- a/NetworkEye/AppDelegate.m +++ b/NetworkEye/AppDelegate.m @@ -9,6 +9,7 @@ #import "AppDelegate.h" #import "DemoViewController.h" #import "NEHTTPEye.h" +#import "NetworkEye/NEHTTPModelManager.h" @interface AppDelegate () @end diff --git a/NetworkEye/DemoViewController.m b/NetworkEye/DemoViewController.m index 9ff2f7e..f3e7cc4 100644 --- a/NetworkEye/DemoViewController.m +++ b/NetworkEye/DemoViewController.m @@ -41,7 +41,8 @@ - (void)setupView{ label.textColor=[UIColor colorWithRed:0.24f green:0.51f blue:0.78f alpha:1.00f]; label.font=[UIFont systemFontOfSize:12]; label.numberOfLines=0; - label.text=@"监控App内所有HTTP请求并显示请求相关的所有信息,方便App开发的网络调试。"; + label.text=@"NetworkEye - a iOS network debug library"; + label.textAlignment=NSTextAlignmentCenter; UIButton *btGoMonitorViewController=[UIButton buttonWithType:UIButtonTypeCustom]; [self.view addSubview:btGoMonitorViewController]; diff --git a/NetworkEye/Info.plist b/NetworkEye/Info.plist index 2a229a9..02ef318 100644 --- a/NetworkEye/Info.plist +++ b/NetworkEye/Info.plist @@ -15,11 +15,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.9.7 + 1.0 CFBundleSignature ???? CFBundleVersion - 0.9.7 + 1.0 LSRequiresIPhoneOS NSAppTransportSecurity diff --git a/NetworkEye/NetworkEye/NEHTTPModelManager.h b/NetworkEye/NetworkEye/NEHTTPModelManager.h index cfc284c..7dad69b 100644 --- a/NetworkEye/NetworkEye/NEHTTPModelManager.h +++ b/NetworkEye/NetworkEye/NEHTTPModelManager.h @@ -15,6 +15,10 @@ FMDatabaseQueue *sqliteDatabase; NSMutableArray *allobjects; } + +@property(nonatomic,strong) NSString *sqlitePassword; +@property(nonatomic,assign) int saveRequestMaxCount; + /** * get recorded requests 's SQLite filename * @@ -32,7 +36,7 @@ /** * create NEHTTPModel table */ -+(void)createTable; +-(void)createTable; /** diff --git a/NetworkEye/NetworkEye/NEHTTPModelManager.m b/NetworkEye/NetworkEye/NEHTTPModelManager.m index eeac42f..ef535a2 100644 --- a/NetworkEye/NetworkEye/NEHTTPModelManager.m +++ b/NetworkEye/NetworkEye/NEHTTPModelManager.m @@ -19,13 +19,24 @@ @implementation NEHTTPModelManager +- (id)init +{ + self = [super init]; + if (self) { + _sqlitePassword=kSQLitePassword; + self.saveRequestMaxCount=kSaveRequestMaxCount; + } + return self; +} + +(NEHTTPModelManager *)defaultManager{ static NEHTTPModelManager *staticManager; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ staticManager=[[NEHTTPModelManager alloc] init]; - [NEHTTPModelManager createTable]; + [staticManager createTable]; + }); return staticManager; @@ -38,14 +49,14 @@ + (NSString *)filename{ return str; } -+(void)createTable{ +- (void)createTable{ NSMutableString *init_sqls=[NSMutableString stringWithCapacity:1024]; [init_sqls appendFormat:@"create table if not exists nenetworkhttpeyes(myID double primary key,startDateString text,endDateString text,requestURLString text,requestCachePolicy text,requestTimeoutInterval double,requestHTTPMethod text,requestAllHTTPHeaderFields text,requestHTTPBody text,responseMIMEType text,responseExpectedContentLength text,responseTextEncodingName text,responseSuggestedFilename text,responseStatusCode int,responseAllHeaderFields text,receiveJSONData text);"]; FMDatabaseQueue *queue= [FMDatabaseQueue databaseQueueWithPath:[NEHTTPModelManager filename]]; [queue inDatabase:^(FMDatabase *db) { - [db setKey:kSQLitePassword]; + [db setKey:_sqlitePassword]; [db executeUpdate:init_sqls]; }]; @@ -72,7 +83,7 @@ -(void)addModel:(NEHTTPModel *) aModel{ receiveJSONData=[self stringToSQLFilter:aModel.receiveJSONData]; NSString *sql=[NSString stringWithFormat:@"insert into nenetworkhttpeyes values('%lf','%@','%@','%@','%@','%lf','%@','%@','%@','%@','%@','%@','%@','%d','%@','%@')",aModel.myID,aModel.startDateString,aModel.endDateString,aModel.requestURLString,aModel.requestCachePolicy,aModel.requestTimeoutInterval,aModel.requestHTTPMethod,aModel.requestAllHTTPHeaderFields,aModel.requestHTTPBody,aModel.responseMIMEType,aModel.responseExpectedContentLength,aModel.responseTextEncodingName,aModel.responseSuggestedFilename,aModel.responseStatusCode,[self stringToSQLFilter:aModel.responseAllHeaderFields],receiveJSONData]; [queue inDatabase:^(FMDatabase *db) { - [db setKey:kSQLitePassword]; + [db setKey:_sqlitePassword]; [db executeUpdate:sql]; }]; @@ -86,7 +97,7 @@ -(NSMutableArray *)allobjects{ NSString *sql =[NSString stringWithFormat:@"select * from nenetworkhttpeyes order by myID desc"]; NSMutableArray *array=[NSMutableArray array]; [queue inDatabase:^(FMDatabase *db) { - [db setKey:kSQLitePassword]; + [db setKey:_sqlitePassword]; FMResultSet *rs = [db executeQuery:sql]; while ([rs next]) { NEHTTPModel *model=[[NEHTTPModel alloc] init]; @@ -110,7 +121,7 @@ -(NSMutableArray *)allobjects{ } }]; - if (array.count>=kSaveRequestMaxCount) { + if (array.count>=self.saveRequestMaxCount) { [[NSUserDefaults standardUserDefaults] setObject:@"a" forKey:@"nenetworkhttpeyecache"]; } @@ -123,7 +134,7 @@ - (void) deleteAllItem{ NSString *sql=[NSString stringWithFormat:@"delete from nenetworkhttpeyes"]; FMDatabaseQueue *queue = [FMDatabaseQueue databaseQueueWithPath:[NEHTTPModelManager filename]]; [queue inDatabase:^(FMDatabase *db) { - [db setKey:kSQLitePassword]; + [db setKey:_sqlitePassword]; [db executeUpdate:sql]; }]; diff --git a/NetworkEye/NetworkEye/NEURLSessionConfiguration.m b/NetworkEye/NetworkEye/NEURLSessionConfiguration.m index cae1bdd..5b8478f 100644 --- a/NetworkEye/NetworkEye/NEURLSessionConfiguration.m +++ b/NetworkEye/NetworkEye/NEURLSessionConfiguration.m @@ -57,11 +57,7 @@ - (void)swizzleSelector:(SEL)selector fromClass:(Class)original toClass:(Class)s } - (NSArray *)protocolClasses { - BOOL NetworkEyeEnable=[[[NSUserDefaults standardUserDefaults] objectForKey:@"NetworkEyeEnable"] boolValue]; - -// if (!NetworkEyeEnable) { -// return @[]; -// } + return @[[NEHTTPEye class]];//如果需要导入其他的自定义NSURLProtocol请在这里增加,当然在使用NSURLSessionConfiguration时增加也可以 } diff --git a/NetworkEye/Resources/networkeye1_3.png b/NetworkEye/Resources/networkeye1_3.png new file mode 100644 index 0000000..4c3eea2 Binary files /dev/null and b/NetworkEye/Resources/networkeye1_3.png differ diff --git a/README.md b/README.md index c482f07..f0d5666 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ welcome to new pull request,that fix bug,add new features,add support other plat ```ruby platform :ios, '7.0' -pod 'NetworkEye', '~> 0.9.9' +pod 'NetworkEye', '~> 1.0' ``` @@ -58,6 +58,11 @@ the database name is networkeye.sqlite,and stored in the cache directory. #define kSaveRequestMaxCount 300 +you can change it use NEHTTPModelManager +
+    [NEHTTPModelManager defaultManager].saveRequestMaxCount=300;
+    [NEHTTPModelManager defaultManager].sqlitePassword=@"networkeye";
+
NetworkEye rely FMDB and SQLCipher。 FMDB be used to store data,SQLCipher be used to encrypt the database。 @@ -65,7 +70,7 @@ Monitoring data interface supports some search conditions ,it is URL,statusCod ####Preview the monitor data interface of NetworkEye: - +