Skip to content

Commit f4d94b0

Browse files
committed
feat: client access functionality (sourceplusplus/sourceplusplus#504)
1 parent 335edbd commit f4d94b0

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

control/src/main/kotlin/spp/probe/ProbeConfiguration.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,19 @@ object ProbeConfiguration {
141141
arrayOf("skywalking.plugin.toolkit.log.transmit_formatted", "false"),
142142
sppSettings.find { it[0] == "spp.platform_host" }?.let {
143143
arrayOf("skywalking.collector.backend_service", it[1] + ":11800")
144+
},
145+
getJsonObject("authentication")?.let {
146+
val clientId = it.getString("client_id")
147+
val clientSecret = it.getString("client_secret")
148+
val tenantId = it.getString("tenant_id")
149+
val authToken = "$clientId:$clientSecret".let {
150+
if (tenantId != null) {
151+
"$it:$tenantId"
152+
} else {
153+
it
154+
}
155+
}
156+
arrayOf("skywalking.agent.authentication", authToken)
144157
}
145158
).filterNotNull().toMutableSet()
146159
}

control/src/main/kotlin/spp/probe/SourceProbe.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ object SourceProbe {
202202
}
203203
socket.result().closeHandler {
204204
connected.set(false)
205-
connectToPlatform()
205+
vertx!!.setTimer(5000) {
206+
connectToPlatform()
207+
}
206208
}
207209

208210
//handle platform messages
@@ -242,6 +244,16 @@ object SourceProbe {
242244
frame.getValue("body")
243245
)
244246
}
247+
} else if ("err" == frame.getString("type")) {
248+
val errorMessage = frame.getString("message")
249+
if (ProbeConfiguration.isNotQuite) {
250+
if (errorMessage == "blocked by bridgeEvent handler") {
251+
System.err.println("Probe authentication failed")
252+
} else {
253+
System.err.println(frame.getString("message"))
254+
}
255+
}
256+
disconnectFromPlatform()
245257
} else {
246258
throw UnsupportedOperationException(frame.toString())
247259
}

0 commit comments

Comments
 (0)