Skip to content

Commit

Permalink
git tag v1.0.5+5 tls server-go
Browse files Browse the repository at this point in the history
  • Loading branch information
matteriot committed Aug 25, 2024
1 parent 5202439 commit b1e5cb9
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [1.0.5+5]

* domain tls

## [1.0.5+4]

* tls call server-go
Expand Down
7 changes: 5 additions & 2 deletions lib/api/Server/ServerChannel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ import 'package:openiothub_api/api/OpenIoTHub/SessionApi.dart';
import 'package:openiothub_api/api/OpenIoTHub/Utils.dart';
import 'package:openiothub_grpc_api/proto/mobile/mobile.pb.dart';

import '../../utils/ip.dart';

class Channel {
static Future<ClientChannel> getServerChannel(String runId) async {
SessionConfig sessionConfig = await SessionApi.getOneSession(runId);
TokenModel tokenModel = await UtilApi.getTokenModel(sessionConfig.token);
final ChannelCredentials credentials = isIp(tokenModel.host) ? const ChannelCredentials.insecure() : const ChannelCredentials.secure();
final channel = ClientChannel(
tokenModel.host,
port: tokenModel.grpcPort,
// options: const ChannelOptions(
// credentials: const ChannelCredentials.insecure())
options: ChannelOptions(
credentials: credentials)
);
return channel;
}
Expand Down
1 change: 1 addition & 0 deletions lib/openiothub_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export './api/OpenIoTHub/SessionApi.dart';
export './api/OpenIoTHub/Utils.dart';
export './api/Server/HttpManager.dart';
export './utils/check.dart';
export './utils/ip.dart';
export './utils/jwt.dart';
export './utils/uuid.dart';
export './utils/zipDevice.dart';
10 changes: 10 additions & 0 deletions lib/utils/ip.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
bool isIp(String ip) {
final pattern = RegExp(r'^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$');
final match = pattern.firstMatch(ip);

if (match == null) {
return false;
}else{
return true;
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: openiothub_api
description: openiothub_api
version: 1.0.5+4
version: 1.0.5+5
homepage: https://github.com/OpenIoTHub
repository: https://github.com/OpenIoTHub/openiothub_api

Expand Down
7 changes: 7 additions & 0 deletions test/ip.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import 'package:openiothub_api/openiothub_api.dart';

void main() async {
print(isIp("192.168.0.1"));
print(isIp("220.205.252.202"));
print(isIp("guonei.servers.iothub.cloud"));
}

0 comments on commit b1e5cb9

Please sign in to comment.