http-api: Include commit hash in User-Agent
This commit is contained in:
@@ -34,6 +34,11 @@
|
||||
<name>Web API</name>
|
||||
<artifactId>http-api</artifactId>
|
||||
|
||||
<properties>
|
||||
<git.commit.id.abbrev>nogit</git.commit.id.abbrev>
|
||||
<git.dirty>false</git.dirty>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
@@ -86,5 +91,31 @@
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>pl.project13.maven</groupId>
|
||||
<artifactId>git-commit-id-plugin</artifactId>
|
||||
<version>2.2.5</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>query-git-info</id>
|
||||
<goals>
|
||||
<goal>revision</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<failOnNoGitDirectory>false</failOnNoGitDirectory>
|
||||
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
|
||||
<gitDescribe>
|
||||
<skip>true</skip>
|
||||
</gitDescribe>
|
||||
<includeOnlyProperties>
|
||||
<includeOnlyProperty>git.commit.id.abbrev</includeOnlyProperty>
|
||||
<includeOnlyProperty>git.dirty</includeOnlyProperty>
|
||||
</includeOnlyProperties>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
@@ -44,6 +44,7 @@ public class RuneLiteAPI
|
||||
|
||||
public static final OkHttpClient CLIENT;
|
||||
public static final Gson GSON = new Gson();
|
||||
public static String userAgent;
|
||||
|
||||
private static final String BASE = "https://api.runelite.net";
|
||||
private static final String WSBASE = "wss://api.runelite.net/runelite-";
|
||||
@@ -61,6 +62,10 @@ public class RuneLiteAPI
|
||||
|
||||
version = properties.getProperty("runelite.version");
|
||||
rsVersion = Integer.parseInt(properties.getProperty("rs.version"));
|
||||
String commit = properties.getProperty("runelite.commit");
|
||||
boolean dirty = Boolean.parseBoolean(properties.getProperty("runelite.dirty"));
|
||||
|
||||
userAgent = "RuneLite/" + version + "-" + commit + (dirty ? "+" : "");
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
@@ -74,14 +79,13 @@ public class RuneLiteAPI
|
||||
CLIENT = new OkHttpClient.Builder()
|
||||
.addNetworkInterceptor(new Interceptor()
|
||||
{
|
||||
private final String USER_AGENT = "RuneLite/" + version;
|
||||
|
||||
@Override
|
||||
public Response intercept(Chain chain) throws IOException
|
||||
{
|
||||
Request userAgentRequest = chain.request()
|
||||
.newBuilder()
|
||||
.header("User-Agent", USER_AGENT)
|
||||
.header("User-Agent", userAgent)
|
||||
.build();
|
||||
return chain.proceed(userAgentRequest);
|
||||
}
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
runelite.version=${project.version}
|
||||
rs.version=${rs.version}
|
||||
rs.version=${rs.version}
|
||||
runelite.commit=${git.commit.id.abbrev}
|
||||
runelite.dirty=${git.dirty}
|
||||
Reference in New Issue
Block a user