Skip to content

Commit 486727d

Browse files
committed
Fix formatting
1 parent b206b60 commit 486727d

91 files changed

Lines changed: 4331 additions & 4346 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.vscode/settings.json‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"deno.enable": true,
3-
"deno.suggest.imports.hosts": {
4-
"https://deno.land": true,
5-
"https://io": false,
6-
"https://d": false,
7-
"https://de": false,
8-
"https://deno": false,
9-
"https://deno.": false,
10-
"https://deno.la": false
11-
}
2+
"deno.enable": true,
3+
"deno.suggest.imports.hosts": {
4+
"https://deno.land": true,
5+
"https://io": false,
6+
"https://d": false,
7+
"https://de": false,
8+
"https://deno": false,
9+
"https://deno.": false,
10+
"https://deno.la": false
11+
}
1212
}

‎bin/conformanceServer.ts‎

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// this server is intended to be used with https://github.com/eclipse/iottestware
22

33
import {
4-
AuthenticationResult,
5-
Context,
6-
MqttServer,
7-
Topic,
4+
AuthenticationResult,
5+
Context,
6+
MqttServer,
7+
Topic,
88
} from "../server/mod.ts";
99
import { logger } from "../utils/utils.ts";
1010

@@ -18,61 +18,61 @@ const notAuthorizedTable = new Set();
1818
notAuthorizedTable.add(["123-456-789", "eclipse/iot/tesware/0data"]);
1919

2020
function isAuthenticated(
21-
_ctx: Context,
22-
clientId: string,
23-
username: string,
24-
password: Uint8Array,
21+
_ctx: Context,
22+
clientId: string,
23+
username: string,
24+
password: Uint8Array,
2525
): AuthenticationResult {
26-
const pwd = utf8Decoder.decode(password);
27-
logger.debug(
28-
`Verifying authentication of client '${clientId}' with username '${username}' and password '${pwd}'`,
29-
);
26+
const pwd = utf8Decoder.decode(password);
27+
logger.debug(
28+
`Verifying authentication of client '${clientId}' with username '${username}' and password '${pwd}'`,
29+
);
3030

31-
if (!userTable.has(username)) {
32-
if (!strictUsername.test(username)) {
33-
return AuthenticationResult.badUsernameOrPassword;
34-
}
35-
}
36-
const pass = userTable.get(username);
37-
if (pwd === pass) {
38-
return AuthenticationResult.ok;
39-
}
40-
return AuthenticationResult.notAuthorized;
31+
if (!userTable.has(username)) {
32+
if (!strictUsername.test(username)) {
33+
return AuthenticationResult.badUsernameOrPassword;
34+
}
35+
}
36+
const pass = userTable.get(username);
37+
if (pwd === pass) {
38+
return AuthenticationResult.ok;
39+
}
40+
return AuthenticationResult.notAuthorized;
4141
}
4242

4343
function isAuthorizedToPublish(ctx: Context, topic: Topic): boolean {
44-
logger.debug(
45-
`Checking authorization of client '${ctx.store?.clientId}' to publish on topic '${topic}'`,
46-
);
47-
// if (notAuthorizedTable.has([ctx.client,topic])){
48-
// return false;
49-
// }
50-
return true;
44+
logger.debug(
45+
`Checking authorization of client '${ctx.store?.clientId}' to publish on topic '${topic}'`,
46+
);
47+
// if (notAuthorizedTable.has([ctx.client,topic])){
48+
// return false;
49+
// }
50+
return true;
5151
}
5252
function isAuthorizedToSubscribe(ctx: Context, topic: Topic): boolean {
53-
logger.debug(
54-
`Checking authorization of client '${ctx.store?.clientId}' to subscribe to topic '${topic}'`,
55-
);
56-
return true;
53+
logger.debug(
54+
`Checking authorization of client '${ctx.store?.clientId}' to subscribe to topic '${topic}'`,
55+
);
56+
return true;
5757
}
5858

5959
/** MQTT server */
6060
const port = Number(Deno.args[0]) || 1883;
6161
const hostname = localhost;
6262
const listener = Deno.listen({ hostname, port });
6363
const mqttServer = new MqttServer({
64-
handlers: {
65-
isAuthenticated,
66-
isAuthorizedToPublish,
67-
isAuthorizedToSubscribe,
68-
},
64+
handlers: {
65+
isAuthenticated,
66+
isAuthorizedToPublish,
67+
isAuthorizedToSubscribe,
68+
},
6969
});
7070
if (listener.addr.transport === "tcp") {
71-
logger.info(
72-
`MQTT server is running on hostname: "${listener.addr.hostname}" port:${listener.addr.port}`,
73-
);
71+
logger.info(
72+
`MQTT server is running on hostname: "${listener.addr.hostname}" port:${listener.addr.port}`,
73+
);
7474
}
7575

7676
for await (const conn of listener) {
77-
mqttServer.serve(conn);
77+
mqttServer.serve(conn);
7878
}

‎bin/demoServer.ts‎

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {
2-
AuthenticationResult,
3-
Context,
4-
MqttServer,
5-
Topic,
2+
AuthenticationResult,
3+
Context,
4+
MqttServer,
5+
Topic,
66
} from "../server/mod.ts";
77
import { logger, LogLevel } from "../utils/utils.ts";
88

@@ -16,60 +16,60 @@ userTable.set("IoTester_2", "strong_password");
1616
// const strictUsername = new RegExp(/^[a-zA-Z0-9]{0,23}$/);
1717

1818
function isAuthenticated(
19-
_ctx: Context,
20-
clientId: string,
21-
username: string,
22-
password: Uint8Array,
19+
_ctx: Context,
20+
clientId: string,
21+
username: string,
22+
password: Uint8Array,
2323
): AuthenticationResult {
24-
const pwd = utf8Decoder.decode(password);
25-
logger.info(
26-
`Verifying authentication of client '${clientId}' with username '${username}' and password '${pwd}'`,
27-
);
24+
const pwd = utf8Decoder.decode(password);
25+
logger.info(
26+
`Verifying authentication of client '${clientId}' with username '${username}' and password '${pwd}'`,
27+
);
2828

29-
return AuthenticationResult.ok;
30-
// if (!userTable.has(username)) {
31-
// if (!strictUsername.test(username)) {
32-
// return AuthenticationResult.badUsernameOrPassword;
33-
// }
34-
// }
29+
return AuthenticationResult.ok;
30+
// if (!userTable.has(username)) {
31+
// if (!strictUsername.test(username)) {
32+
// return AuthenticationResult.badUsernameOrPassword;
33+
// }
34+
// }
3535

36-
// const pass = userTable.get(username);
37-
// if (pwd === pass) {
38-
// return AuthenticationResult.ok;
39-
// }
40-
// return AuthenticationResult.badUsernameOrPassword;
36+
// const pass = userTable.get(username);
37+
// if (pwd === pass) {
38+
// return AuthenticationResult.ok;
39+
// }
40+
// return AuthenticationResult.badUsernameOrPassword;
4141
}
4242

4343
function isAuthorizedToPublish(ctx: Context, topic: Topic): boolean {
44-
logger.debug(
45-
`Checking authorization of client '${ctx.store?.clientId}' to publish on topic '${topic}'`,
46-
);
47-
return true;
44+
logger.debug(
45+
`Checking authorization of client '${ctx.store?.clientId}' to publish on topic '${topic}'`,
46+
);
47+
return true;
4848
}
4949
function isAuthorizedToSubscribe(ctx: Context, topic: Topic): boolean {
50-
logger.debug(
51-
`Checking authorization of client '${ctx.store?.clientId}' to subscribe to topic '${topic}'`,
52-
);
53-
return true;
50+
logger.debug(
51+
`Checking authorization of client '${ctx.store?.clientId}' to subscribe to topic '${topic}'`,
52+
);
53+
return true;
5454
}
5555

5656
/** MQTT server */
5757
const port = Number(Deno.args[0]) || 1883;
5858
const hostname = localhost;
5959
const listener = Deno.listen({ hostname, port });
6060
const mqttServer = new MqttServer({
61-
handlers: {
62-
isAuthenticated,
63-
isAuthorizedToPublish,
64-
isAuthorizedToSubscribe,
65-
},
61+
handlers: {
62+
isAuthenticated,
63+
isAuthorizedToPublish,
64+
isAuthorizedToSubscribe,
65+
},
6666
});
6767
if (listener.addr.transport === "tcp") {
68-
logger.info(
69-
`MQTT server is running on hostname: "${listener.addr.hostname}" port:${listener.addr.port}`,
70-
);
68+
logger.info(
69+
`MQTT server is running on hostname: "${listener.addr.hostname}" port:${listener.addr.port}`,
70+
);
7171
}
7272

7373
for await (const conn of listener) {
74-
mqttServer.serve(conn);
74+
mqttServer.serve(conn);
7575
}

0 commit comments

Comments
 (0)