diff --git a/server/src/main/java/com/soulfiremc/server/grpc/DownloadServiceImpl.java b/server/src/main/java/com/soulfiremc/server/grpc/DownloadServiceImpl.java index 6953c379..e275ea66 100644 --- a/server/src/main/java/com/soulfiremc/server/grpc/DownloadServiceImpl.java +++ b/server/src/main/java/com/soulfiremc/server/grpc/DownloadServiceImpl.java @@ -19,25 +19,33 @@ import com.google.protobuf.ByteString; import com.soulfiremc.grpc.generated.*; +import com.soulfiremc.server.proxy.SFProxy; import com.soulfiremc.server.user.PermissionContext; import com.soulfiremc.server.util.ReactorHttpHelper; import io.grpc.Status; import io.grpc.StatusRuntimeException; import io.grpc.stub.StreamObserver; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.Nullable; import java.net.URI; import java.util.UUID; +import java.util.function.BooleanSupplier; +import java.util.function.Supplier; @Slf4j public class DownloadServiceImpl extends DownloadServiceGrpc.DownloadServiceImplBase { + public static @Nullable SFProxy convertProxy(BooleanSupplier hasProxy, Supplier proxy) { + return hasProxy.getAsBoolean() ? SFProxy.fromProto(proxy.get()) : null; + } + @Override public void download(DownloadRequest request, StreamObserver responseObserver) { var instanceId = UUID.fromString(request.getInstanceId()); ServerRPCConstants.USER_CONTEXT_KEY.get().hasPermissionOrThrow(PermissionContext.instance(InstancePermission.DOWNLOAD_URL, instanceId)); try { - var proxy = RPCUtils.convertProxy(request::hasProxy, request::getProxy); + var proxy = convertProxy(request::hasProxy, request::getProxy); ReactorHttpHelper.createReactorClient(proxy, false) .headers(h -> request.getHeadersList().forEach(header -> h.set(header.getKey(), header.getValue()))) .get() diff --git a/server/src/main/java/com/soulfiremc/server/grpc/RPCUtils.java b/server/src/main/java/com/soulfiremc/server/grpc/RPCUtils.java deleted file mode 100644 index 6293cf61..00000000 --- a/server/src/main/java/com/soulfiremc/server/grpc/RPCUtils.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SoulFire - * Copyright (C) 2024 AlexProgrammerDE - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.soulfiremc.server.grpc; - -import com.soulfiremc.grpc.generated.ProxyProto; -import com.soulfiremc.server.proxy.SFProxy; -import org.jetbrains.annotations.Nullable; - -import java.util.function.BooleanSupplier; -import java.util.function.Supplier; - -public class RPCUtils { - public static @Nullable SFProxy convertProxy(BooleanSupplier hasProxy, Supplier proxy) { - return hasProxy.getAsBoolean() ? SFProxy.fromProto(proxy.get()) : null; - } -}