mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 23:18:17 +01:00
Merge pull request #6365 from ghubstan/remove-relay-subproject
Remove gradle subproject :relay
This commit is contained in:
commit
6203cf7c29
8 changed files with 0 additions and 327 deletions
26
build.gradle
26
build.gradle
|
@ -38,7 +38,6 @@ configure(subprojects) {
|
|||
easybindVersion = '1.0.3'
|
||||
easyVersion = '4.0.1'
|
||||
findbugsVersion = '3.0.2'
|
||||
firebaseVersion = '6.2.0'
|
||||
fontawesomefxVersion = '8.0.0'
|
||||
fontawesomefxCommonsVersion = '9.1.2'
|
||||
fontawesomefxMaterialdesignfontVersion = '2.0.26-9.1.2'
|
||||
|
@ -71,10 +70,8 @@ configure(subprojects) {
|
|||
netlayerVersion = '0.7.4'
|
||||
protobufVersion = '3.19.1'
|
||||
protocVersion = protobufVersion
|
||||
pushyVersion = '0.13.2'
|
||||
qrgenVersion = '1.3'
|
||||
slf4jVersion = '1.7.30'
|
||||
sparkVersion = '2.5.2'
|
||||
springBootVersion = '2.5.6'
|
||||
|
||||
os = osdetector.os == 'osx' ? 'mac' : osdetector.os == 'windows' ? 'win' : osdetector.os
|
||||
|
@ -99,7 +96,6 @@ configure([project(':cli'),
|
|||
project(':daemon'),
|
||||
project(':desktop'),
|
||||
project(':monitor'),
|
||||
project(':relay'),
|
||||
project(':seednode'),
|
||||
project(':statsnode'),
|
||||
project(':pricenode'),
|
||||
|
@ -633,28 +629,6 @@ configure(project(':pricenode')) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
configure(project(':relay')) {
|
||||
mainClassName = 'bisq.relay.RelayMain'
|
||||
|
||||
dependencies {
|
||||
implementation project(':common')
|
||||
implementation "ch.qos.logback:logback-classic:$logbackVersion"
|
||||
implementation "ch.qos.logback:logback-core:$logbackVersion"
|
||||
implementation("com.google.firebase:firebase-admin:$firebaseVersion") {
|
||||
exclude(module: 'commons-logging')
|
||||
exclude(module: 'grpc-auth')
|
||||
exclude(module: 'httpclient')
|
||||
exclude(module: 'httpcore')
|
||||
}
|
||||
implementation "com.sparkjava:spark-core:$sparkVersion"
|
||||
implementation "com.turo:pushy:$pushyVersion"
|
||||
implementation "commons-codec:commons-codec:$codecVersion"
|
||||
implementation "io.grpc:grpc-auth:$grpcVersion"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
configure(project(':seednode')) {
|
||||
apply plugin: 'com.github.johnrengelman.shadow'
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
web: if [ "$HIDDEN" == true ]; then ./tor/bin/run_tor java -jar -Dserver.port=$PORT build/libs/bisq-relay.jar; else java -jar -Dserver.port=$PORT build/libs/bisq-relay.jar; fi
|
|
@ -1,125 +0,0 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.relay;
|
||||
|
||||
import bisq.common.app.Log;
|
||||
import bisq.common.util.Utilities;
|
||||
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ch.qos.logback.classic.Level;
|
||||
|
||||
import static spark.Spark.get;
|
||||
import static spark.Spark.port;
|
||||
|
||||
public class RelayMain {
|
||||
private static final Logger log = LoggerFactory.getLogger(RelayMain.class);
|
||||
private static final String VERSION = "0.1.0";
|
||||
private static RelayService relayService;
|
||||
|
||||
static {
|
||||
// Need to set default locale initially otherwise we get problems at non-English OS
|
||||
Locale.setDefault(new Locale("en", Locale.getDefault().getCountry()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param args Pass port as program argument if other port than default port 8080 is wanted.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
final String logPath = System.getProperty("user.home") + File.separator + "provider";
|
||||
Log.setup(logPath);
|
||||
Log.setLevel(Level.INFO);
|
||||
log.info("Log files under: " + logPath);
|
||||
log.info("RelayVersion.VERSION: " + VERSION);
|
||||
Utilities.printSysInfo();
|
||||
|
||||
|
||||
String appleCertPwPath;
|
||||
if (args.length > 0)
|
||||
appleCertPwPath = args[0];
|
||||
else
|
||||
throw new RuntimeException("You need to set the path to the password text file for the Apple push certificate as first argument.");
|
||||
|
||||
String appleCertPath;
|
||||
if (args.length > 1)
|
||||
appleCertPath = args[1];
|
||||
else
|
||||
throw new RuntimeException("You need to set the path to the Apple push certificate as second argument.");
|
||||
|
||||
String appleBundleId;
|
||||
if (args.length > 2)
|
||||
appleBundleId = args[2];
|
||||
else
|
||||
throw new RuntimeException("You need to set the Apple bundle ID as third argument.");
|
||||
|
||||
String androidCertPath;
|
||||
if (args.length > 3)
|
||||
androidCertPath = args[3];
|
||||
else
|
||||
throw new RuntimeException("You need to set the Android certificate path as 4th argument.");
|
||||
|
||||
|
||||
int port = 8080;
|
||||
if (args.length > 4)
|
||||
port = Integer.parseInt(args[4]);
|
||||
|
||||
port(port);
|
||||
|
||||
relayService = new RelayService(appleCertPwPath, appleCertPath, appleBundleId, androidCertPath);
|
||||
|
||||
handleRelay();
|
||||
|
||||
keepRunning();
|
||||
}
|
||||
|
||||
private static void handleRelay() {
|
||||
get("/relay", (request, response) -> {
|
||||
log.info("Incoming relay request from: " + request.userAgent());
|
||||
boolean isAndroid = request.queryParams("isAndroid").equalsIgnoreCase("true");
|
||||
boolean useSound = request.queryParams("snd").equalsIgnoreCase("true");
|
||||
String token = new String(Hex.decodeHex(request.queryParams("token").toCharArray()), "UTF-8");
|
||||
String encryptedMessage = new String(Hex.decodeHex(request.queryParams("msg").toCharArray()), "UTF-8");
|
||||
log.info("isAndroid={}\nuseSound={}\napsTokenHex={}\nencryptedMessage={}", isAndroid, useSound, token,
|
||||
encryptedMessage);
|
||||
if (isAndroid) {
|
||||
return relayService.sendAndroidMessage(token, encryptedMessage, useSound);
|
||||
} else {
|
||||
boolean isProduction = request.queryParams("isProduction").equalsIgnoreCase("true");
|
||||
boolean isContentAvailable = request.queryParams("isContentAvailable").equalsIgnoreCase("true");
|
||||
return relayService.sendAppleMessage(isProduction, isContentAvailable, token, encryptedMessage, useSound);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void keepRunning() {
|
||||
//noinspection InfiniteLoopStatement
|
||||
while (true) {
|
||||
try {
|
||||
Thread.sleep(Long.MAX_VALUE);
|
||||
} catch (InterruptedException ignore) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,156 +0,0 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.relay;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import java.util.Scanner;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
|
||||
import com.google.auth.oauth2.GoogleCredentials;
|
||||
import com.google.firebase.FirebaseApp;
|
||||
import com.google.firebase.FirebaseOptions;
|
||||
import com.google.firebase.messaging.FirebaseMessaging;
|
||||
import com.google.firebase.messaging.FirebaseMessagingException;
|
||||
import com.google.firebase.messaging.Message;
|
||||
import com.google.firebase.messaging.Notification;
|
||||
import com.turo.pushy.apns.ApnsClient;
|
||||
import com.turo.pushy.apns.ApnsClientBuilder;
|
||||
import com.turo.pushy.apns.PushNotificationResponse;
|
||||
import com.turo.pushy.apns.util.ApnsPayloadBuilder;
|
||||
import com.turo.pushy.apns.util.SimpleApnsPushNotification;
|
||||
import com.turo.pushy.apns.util.concurrent.PushNotificationFuture;
|
||||
|
||||
class RelayService {
|
||||
private static final Logger log = LoggerFactory.getLogger(RelayMain.class);
|
||||
private static final String ANDROID_DATABASE_URL = "https://bisqnotifications.firebaseio.com";
|
||||
// Used in Bisq app to check for success state. We won't want a code dependency just for that string so we keep it
|
||||
// duplicated in core and here. Must not be changed.
|
||||
private static final String SUCCESS = "success";
|
||||
|
||||
private final String appleBundleId;
|
||||
|
||||
private ApnsClient productionApnsClient;
|
||||
private ApnsClient devApnsClient; // used for iOS development in XCode
|
||||
|
||||
RelayService(String appleCertPwPath, String appleCertPath, String appleBundleId, String androidCertPath) {
|
||||
this.appleBundleId = appleBundleId;
|
||||
|
||||
setupForAndroid(androidCertPath);
|
||||
setupForApple(appleCertPwPath, appleCertPath);
|
||||
}
|
||||
|
||||
private void setupForAndroid(String androidCertPath) {
|
||||
try {
|
||||
InputStream androidCertStream = new FileInputStream(androidCertPath);
|
||||
FirebaseOptions options = new FirebaseOptions.Builder()
|
||||
.setCredentials(GoogleCredentials.fromStream(androidCertStream))
|
||||
.setDatabaseUrl(ANDROID_DATABASE_URL)
|
||||
.build();
|
||||
FirebaseApp.initializeApp(options);
|
||||
} catch (IOException e) {
|
||||
log.error(e.toString());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void setupForApple(String appleCertPwPath, String appleCertPath) {
|
||||
try {
|
||||
InputStream certInputStream = new FileInputStream(appleCertPwPath);
|
||||
Scanner scanner = new Scanner(certInputStream);
|
||||
String password = scanner.next();
|
||||
productionApnsClient = new ApnsClientBuilder()
|
||||
.setApnsServer(ApnsClientBuilder.PRODUCTION_APNS_HOST)
|
||||
.setClientCredentials(new File(appleCertPath), password)
|
||||
.build();
|
||||
devApnsClient = new ApnsClientBuilder()
|
||||
.setApnsServer(ApnsClientBuilder.DEVELOPMENT_APNS_HOST)
|
||||
.setClientCredentials(new File(appleCertPath), password)
|
||||
.build();
|
||||
} catch (IOException e) {
|
||||
log.error(e.toString());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
String sendAppleMessage(boolean isProduction, boolean isContentAvailable, String apsTokenHex, String encryptedMessage, boolean useSound) {
|
||||
ApnsPayloadBuilder payloadBuilder = new ApnsPayloadBuilder();
|
||||
if (useSound)
|
||||
payloadBuilder.setSoundFileName("default");
|
||||
payloadBuilder.setAlertBody("Bisq notification");
|
||||
payloadBuilder.setContentAvailable(isContentAvailable);
|
||||
payloadBuilder.addCustomProperty("encrypted", encryptedMessage);
|
||||
final String payload = payloadBuilder.buildWithDefaultMaximumLength();
|
||||
log.info("payload " + payload);
|
||||
SimpleApnsPushNotification simpleApnsPushNotification = new SimpleApnsPushNotification(apsTokenHex, appleBundleId, payload);
|
||||
|
||||
ApnsClient apnsClient = isProduction ? productionApnsClient : devApnsClient;
|
||||
PushNotificationFuture<SimpleApnsPushNotification, PushNotificationResponse<SimpleApnsPushNotification>>
|
||||
notificationFuture = apnsClient.sendNotification(simpleApnsPushNotification);
|
||||
try {
|
||||
PushNotificationResponse<SimpleApnsPushNotification> pushNotificationResponse = notificationFuture.get();
|
||||
if (pushNotificationResponse.isAccepted()) {
|
||||
log.info("Push notification accepted by APNs gateway.");
|
||||
return SUCCESS;
|
||||
} else {
|
||||
String msg1 = "Notification rejected by the APNs gateway: " +
|
||||
pushNotificationResponse.getRejectionReason();
|
||||
String msg2 = "";
|
||||
if (pushNotificationResponse.getTokenInvalidationTimestamp() != null)
|
||||
msg2 = " and the token is invalid as of " +
|
||||
pushNotificationResponse.getTokenInvalidationTimestamp();
|
||||
|
||||
log.info(msg1 + msg2);
|
||||
return "Error: " + msg1 + msg2;
|
||||
}
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
log.error(e.toString());
|
||||
e.printStackTrace();
|
||||
return "Error: " + e.toString();
|
||||
}
|
||||
}
|
||||
|
||||
String sendAndroidMessage(String apsTokenHex, String encryptedMessage, boolean useSound) {
|
||||
Message.Builder messageBuilder = Message.builder();
|
||||
Notification notification = new Notification("Bisq", "Notification");
|
||||
messageBuilder.setNotification(notification);
|
||||
messageBuilder.putData("encrypted", encryptedMessage);
|
||||
messageBuilder.setToken(apsTokenHex);
|
||||
if (useSound)
|
||||
messageBuilder.putData("sound", "default");
|
||||
Message message = messageBuilder.build();
|
||||
try {
|
||||
FirebaseMessaging firebaseMessaging = FirebaseMessaging.getInstance();
|
||||
firebaseMessaging.send(message);
|
||||
return SUCCESS;
|
||||
} catch (FirebaseMessagingException e) {
|
||||
log.error(e.toString());
|
||||
e.printStackTrace();
|
||||
return "Error: " + e.toString();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="CONSOLE_APPENDER" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%highlight(%d{MMM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{15}: %msg %xEx%n)</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="WARN">
|
||||
<appender-ref ref="CONSOLE_APPENDER"/>
|
||||
</root>
|
||||
|
||||
<logger name="bisq" level="INFO"/>
|
||||
|
||||
</configuration>
|
|
@ -1 +0,0 @@
|
|||
1.9.5-SNAPSHOT
|
|
@ -1,2 +0,0 @@
|
|||
HiddenServiceDir build/tor-hidden-service
|
||||
HiddenServicePort 80 127.0.0.1:8080
|
|
@ -8,7 +8,6 @@ include 'daemon'
|
|||
include 'desktop'
|
||||
include 'monitor'
|
||||
include 'pricenode'
|
||||
include 'relay'
|
||||
include 'seednode'
|
||||
include 'statsnode'
|
||||
include 'apitest'
|
||||
|
|
Loading…
Add table
Reference in a new issue