Skip to content

Commit

Permalink
feat: ci/cd & new requests
Browse files Browse the repository at this point in the history
  • Loading branch information
dynomake committed May 8, 2024
1 parent 4975721 commit 021e922
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 27 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Publish

on: push
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
server-id: github
settings-path: ${{ github.workspace }}

- name: Run chmod to make gradlew executable
run: chmod +x ./gradlew

- name: Build and Publish
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
env:
deployUser: ${{ secrets.CLOJARS_USER }}
deployToken: ${{ secrets.CLOJARS_TOKEN }}
with:
arguments: publish
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ maven {
```
Depend:
```groovy
implementation 'io.github.dynomake:outline-java-wrapper:1.0.0'
implementation 'io.github.dynomake:outline-java-wrapper:1.0.2'
```

### | `Maven`:
Expand All @@ -35,7 +35,7 @@ Depend:
<dependency>
<groupId>io.github.dynomake</groupId>
<artifactId>outline-java-wrapper</artifactId>
<version>1.0.0</version>
<version>1.0.2</version>
</dependency>
```

Expand Down
19 changes: 14 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ plugins {
}

group 'io.github.dynomake'
version '1.0.0'
version '1.0.2'

sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility = 17
targetCompatibility = 17

repositories {
mavenCentral()
Expand All @@ -29,15 +29,24 @@ publishing {
name = "clojars"
url = uri("https://clojars.org/repo")
credentials {
username = clojarsUserName
password = clojarsDeployToken
username = "$System.env.deployUser"
password = "$System.env.deployToken"
}
}

}
publications {
gpr(MavenPublication) {
from(components.java)

pom {
licenses {
license {
name = 'MIT License'
url = 'https://github.com/dynomake/outline-java-wrapper/blob/master/LICENSE'
}
}
}
}
}
}
6 changes: 3 additions & 3 deletions src/main/java/me/dynomake/outline/OutlineWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import me.dynomake.outline.model.OutlineServer;

/**
* Shadowsocks Java Wrapper written by dynomake developer.
* Outline Java Wrapper written by dynomake developer.
* Distributed by MIT License.
*/
public interface OutlineWrapper {
Expand All @@ -19,9 +19,9 @@ static OutlineWrapper create(@NonNull String apiAddress) {
OutlineKeyList getKeys();

OutlineKey generateKey();

OutlineKey getKey(int keyIdentifier);
void renameKey(int keyIdentifier, @NonNull String name);
boolean removeKey(int keyIdentifier);

OutlineServer getServerInformation();

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.NonNull;
import me.dynomake.outline.OutlineWrapper;
import me.dynomake.outline.gson.GsonUtil;
import me.dynomake.outline.implementation.model.Name;
import me.dynomake.outline.model.OutlineKey;
import me.dynomake.outline.model.OutlineKeyList;
import me.dynomake.outline.model.OutlineServer;
Expand All @@ -18,9 +19,10 @@
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.Scanner;
import java.util.function.Consumer;

/**
* Shadowsocks Java Wrapper written by dynomake developer.
* Outline Java Wrapper written by dynomake developer.
* Distributed by MIT License.
*/
@AllArgsConstructor
Expand All @@ -38,6 +40,16 @@ public OutlineKey generateKey() {
return GsonUtil.unparseJson(getResponse("/access-keys", "POST", null).responseString, OutlineKey.class);
}

@Override
public OutlineKey getKey(int keyIdentifier) {
return GsonUtil.unparseJson(getResponse("/access-keys/" + keyIdentifier, "GET", null).responseString, OutlineKey.class);
}

@Override
public void renameKey(int keyIdentifier, @NonNull String name) {
getResponse("/access-keys/" + keyIdentifier + "/name", "PUT", GsonUtil.parseJson(new Name(name)));
}

@Override
public boolean removeKey(int keyIdentifier) {
return getResponse("/access-keys/" + keyIdentifier, "DELETE", null).responseCode == 204;
Expand All @@ -57,9 +69,9 @@ private Response getResponse(@NonNull String requestAddress, @NonNull String met

httpConn.setRequestMethod(method);
removeSSLVerifier(httpConn);

if (writableJson != null) {
httpConn.setDoOutput(true);
httpConn.setRequestProperty("Content-Type", "application/json");
OutputStreamWriter writer = new OutputStreamWriter(httpConn.getOutputStream());
writer.write(writableJson);
writer.flush();
Expand Down Expand Up @@ -112,12 +124,7 @@ public void checkServerTrusted(X509Certificate[] arg0, String arg1)
}
connection.setSSLSocketFactory(sc.getSocketFactory());

HostnameVerifier validHosts = new HostnameVerifier() {
@Override
public boolean verify(String arg0, SSLSession arg1) {
return true;
}
};
HostnameVerifier validHosts = (arg0, arg1) -> true;

connection.setHostnameVerifier(validHosts);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package me.dynomake.outline.implementation.model;

import lombok.AllArgsConstructor;

@AllArgsConstructor
public class Name {
private String name;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import lombok.experimental.FieldDefaults;

/**
* Shadowsocks Java Wrapper written by dynomake developer.
* Outline Java Wrapper written by dynomake developer.
* Distributed by MIT License.
*/
@AllArgsConstructor
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/dynomake/outline/model/LimitModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import lombok.experimental.FieldDefaults;

/**
* Shadowsocks Java Wrapper written by dynomake developer.
* Outline Java Wrapper written by dynomake developer.
* Distributed by MIT License.
*/
@AllArgsConstructor
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/dynomake/outline/model/OutlineKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import lombok.experimental.FieldDefaults;

/**
* Shadowsocks Java Wrapper written by dynomake developer.
* Outline Java Wrapper written by dynomake developer.
* Distributed by MIT License.
*/
@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.List;

/**
* Shadowsocks Java Wrapper written by dynomake developer.
* Outline Java Wrapper written by dynomake developer.
* Distributed by MIT License.
*/
@AllArgsConstructor
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/dynomake/outline/model/OutlineServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.UUID;

/**
* Shadowsocks Java Wrapper written by dynomake developer.
* Outline Java Wrapper written by dynomake developer.
* Distributed by MIT License.
*/
@AllArgsConstructor
Expand Down
12 changes: 8 additions & 4 deletions src/test/java/me/dynomake/outline/LittleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

public class LittleTest {
public static void main(String[] args) {

OutlineWrapper outlineWrapper = OutlineWrapper.create("https://127.0.0.1:50912/api");

System.out.println("server: " + outlineWrapper.getServerInformation().name);
System.out.println("in server keys: " + outlineWrapper.getKeys().accessKeys.size());
int newKeyId = outlineWrapper.generateKey().id;
System.out.println("new key: " + newKeyId);
System.out.println("new key delete result: " + outlineWrapper.removeKey(newKeyId));
outlineWrapper.renameKey(70, "heller");

for (var key: outlineWrapper.getKeys().accessKeys) {
System.out.println("key with id " + key.id + ", url is " + key.accessUrl + " name " + key.name);
}



}
}

0 comments on commit 021e922

Please sign in to comment.