Skip to content

wujingwe/quickconnect-interceptor-kotlin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QuickConnectInterceptor

An OkHttp application interceptor for Synology Quick Connect

What is OkHttp application interceptor?

A powerful tool introduced by OkHttp. We use it to resolve real IP address before sending request to Synology NAS server, detailed information can be found here.

What is Synology Quick Connect?

Synology Inc. (Chinese: 群暉科技) is a Taiwanese corporation that specializes in network attached storage (NAS) appliances. QuickConnect is designed to make connecting Synology NAS servers easy and quick, even NAS is behind NAT. You can find the white paper here.

What is Kotlin(programming language)

Kotlin is a modern programming language that runs on the Java Virtual Machine. It provides lots of advantages compared with Java and is considerable to be a replacement(especially for Android which can only support Java 1.7 currently.)

  • Null-safety
  • Lambda expressions
  • Extension functions
  • Properties and more...

How to use

  • Add jar in buid.gradle
compile project (':quickconnect')
  • Add QuickConnectInterceptor when creating OkHttpClient
val client = 
    OkHttpClient.Builder()
        .addInterceptor(QuickConnectInterceptor())
        .build()
  • Send a request to Synology NAS server. To use QuickConnect, you need to have a QuickConnect ID. To compose a HTTP request, replace hostname with QuickConnect ID. For example, if your QuickConnect ID is "dsm" and want to send a pingpong request(webman/pingpong.cgi?action=cors), the request should be looked like:
val quickConnectId = "dsm"
val request = 
    Request.Builder()
        .url(HttpUrl.parse("http://$quickConnectId/webman/pingpong.cgi?action=cors"))
        .build();
client.newCall(request).execute();

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and 
limitations under the License.

About

Synology QuickConnect Interceptor written in Kotlin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages