mirror of
https://github.com/amnezia-vpn/amneziawg-android.git
synced 2026-07-03 14:05:13 +02:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b514717076 | |||
| 23932952d8 | |||
| 266ee7626c | |||
| c1ba1f409c | |||
| 0f669e8ca3 | |||
| 9de711a4f5 | |||
| e1965f121c | |||
| b2c9b3500c | |||
| f60d26c4bf | |||
| b43044fee9 | |||
| 2bc66e4574 | |||
| a641a093ad |
+2
-2
@@ -17,8 +17,8 @@ android {
|
||||
applicationId 'com.wireguard.android'
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 28
|
||||
versionCode 444
|
||||
versionName '0.0.20181207'
|
||||
versionCode 445
|
||||
versionName '0.0.20181210'
|
||||
buildConfigField 'int', 'MIN_SDK_VERSION', "$minSdkVersion.apiLevel"
|
||||
}
|
||||
// If the keystore file exists
|
||||
|
||||
@@ -57,7 +57,7 @@ public interface Backend {
|
||||
*
|
||||
* @return Type name
|
||||
*/
|
||||
String getTypeName();
|
||||
String getTypePrettyName();
|
||||
|
||||
/**
|
||||
* Determine version of underlying backend.
|
||||
|
||||
@@ -14,6 +14,7 @@ import android.support.v4.util.ArraySet;
|
||||
import android.util.Log;
|
||||
|
||||
import com.wireguard.android.Application;
|
||||
import com.wireguard.android.R;
|
||||
import com.wireguard.android.activity.MainActivity;
|
||||
import com.wireguard.android.model.Tunnel;
|
||||
import com.wireguard.android.model.Tunnel.State;
|
||||
@@ -26,6 +27,7 @@ import com.wireguard.config.Peer;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.Collections;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -93,8 +95,8 @@ public final class GoBackend implements Backend {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return "Go userspace";
|
||||
public String getTypePrettyName() {
|
||||
return context.getResources().getString(R.string.type_name_go_userspace);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -110,7 +112,7 @@ public final class GoBackend implements Backend {
|
||||
if (state == originalState)
|
||||
return originalState;
|
||||
if (state == State.UP && currentTunnel != null)
|
||||
throw new IllegalStateException("Only one userspace tunnel can run at a time");
|
||||
throw new IllegalStateException(context.getResources().getString(R.string.multiple_tunnels_error));
|
||||
Log.d(TAG, "Changing tunnel " + tunnel.getName() + " to state " + state);
|
||||
setStateInternal(tunnel, tunnel.getConfig(), state);
|
||||
return getState(tunnel);
|
||||
@@ -122,10 +124,10 @@ public final class GoBackend implements Backend {
|
||||
if (state == State.UP) {
|
||||
Log.i(TAG, "Bringing tunnel up");
|
||||
|
||||
Objects.requireNonNull(config, "Trying to bring up a tunnel with no config");
|
||||
Objects.requireNonNull(config, context.getResources().getString(R.string.no_config_error));
|
||||
|
||||
if (VpnService.prepare(context) != null)
|
||||
throw new Exception("VPN service not authorized by user");
|
||||
throw new Exception(context.getResources().getString(R.string.vpn_not_authed_error));
|
||||
|
||||
final VpnService service;
|
||||
if (!vpnService.isDone())
|
||||
@@ -134,7 +136,7 @@ public final class GoBackend implements Backend {
|
||||
try {
|
||||
service = vpnService.get(2, TimeUnit.SECONDS);
|
||||
} catch (final TimeoutException e) {
|
||||
throw new Exception("Unable to start Android VPN service", e);
|
||||
throw new Exception(context.getResources().getString(R.string.vpn_start_error), e);
|
||||
}
|
||||
|
||||
if (currentTunnelHandle != -1) {
|
||||
@@ -172,12 +174,12 @@ public final class GoBackend implements Backend {
|
||||
builder.setBlocking(true);
|
||||
try (final ParcelFileDescriptor tun = builder.establish()) {
|
||||
if (tun == null)
|
||||
throw new Exception("Unable to create tun device");
|
||||
throw new Exception(context.getResources().getString(R.string.tun_create_error));
|
||||
Log.d(TAG, "Go backend v" + wgVersion());
|
||||
currentTunnelHandle = wgTurnOn(tunnel.getName(), tun.detachFd(), goConfig);
|
||||
}
|
||||
if (currentTunnelHandle < 0)
|
||||
throw new Exception("Unable to turn tunnel on (wgTurnOn return " + currentTunnelHandle + ')');
|
||||
throw new Exception(String.format(Locale.getDefault(), context.getResources().getString(R.string.tunnel_on_error), currentTunnelHandle));
|
||||
|
||||
currentTunnel = tunnel;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
|
||||
import com.wireguard.android.Application;
|
||||
import com.wireguard.android.R;
|
||||
import com.wireguard.android.model.Tunnel;
|
||||
import com.wireguard.android.model.Tunnel.State;
|
||||
import com.wireguard.android.model.Tunnel.Statistics;
|
||||
@@ -21,6 +22,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -35,9 +37,11 @@ public final class WgQuickBackend implements Backend {
|
||||
private static final String TAG = "WireGuard/" + WgQuickBackend.class.getSimpleName();
|
||||
|
||||
private final File localTemporaryDir;
|
||||
private final Context context;
|
||||
|
||||
public WgQuickBackend(final Context context) {
|
||||
localTemporaryDir = new File(context.getCacheDir(), "tmp");
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,8 +87,8 @@ public final class WgQuickBackend implements Backend {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return "Kernel module";
|
||||
public String getTypePrettyName() {
|
||||
return context.getResources().getString(R.string.type_name_kernel_module);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,7 +96,7 @@ public final class WgQuickBackend implements Backend {
|
||||
final List<String> output = new ArrayList<>();
|
||||
if (Application.getRootShell()
|
||||
.run(output, "cat /sys/module/wireguard/version") != 0 || output.isEmpty())
|
||||
throw new Exception("Unable to determine kernel module version");
|
||||
throw new Exception(context.getResources().getString(R.string.module_version_error));
|
||||
return output.get(0);
|
||||
}
|
||||
|
||||
@@ -117,13 +121,13 @@ public final class WgQuickBackend implements Backend {
|
||||
stream.write(config.toWgQuickString().getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
String command = String.format("wg-quick %s '%s'",
|
||||
state.toString().toLowerCase(), tempFile.getAbsolutePath());
|
||||
state.toString().toLowerCase(Locale.ENGLISH), tempFile.getAbsolutePath());
|
||||
if (state == State.UP)
|
||||
command = "cat /sys/module/wireguard/version && " + command;
|
||||
final int result = Application.getRootShell().run(null, command);
|
||||
// noinspection ResultOfMethodCallIgnored
|
||||
tempFile.delete();
|
||||
if (result != 0)
|
||||
throw new Exception("Unable to configure tunnel (wg-quick returned " + result + ')');
|
||||
throw new Exception(context.getResources().getString(R.string.tunnel_config_error));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ package com.wireguard.android.configStore;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.wireguard.android.R;
|
||||
import com.wireguard.config.Config;
|
||||
import com.wireguard.config.ParseException;
|
||||
|
||||
@@ -17,6 +18,7 @@ import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import java9.util.stream.Collectors;
|
||||
@@ -40,7 +42,8 @@ public final class FileConfigStore implements ConfigStore {
|
||||
Log.d(TAG, "Creating configuration for tunnel " + name);
|
||||
final File file = fileFor(name);
|
||||
if (!file.createNewFile())
|
||||
throw new IOException("Configuration file " + file.getName() + " already exists");
|
||||
throw new IOException(String.format(Locale.getDefault(),
|
||||
context.getResources().getString(R.string.config_file_exists_error), file.getName()));
|
||||
try (final FileOutputStream stream = new FileOutputStream(file, false)) {
|
||||
stream.write(config.toWgQuickString().getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
@@ -52,7 +55,8 @@ public final class FileConfigStore implements ConfigStore {
|
||||
Log.d(TAG, "Deleting configuration for tunnel " + name);
|
||||
final File file = fileFor(name);
|
||||
if (!file.delete())
|
||||
throw new IOException("Cannot delete configuration file " + file.getName());
|
||||
throw new IOException(String.format(Locale.getDefault(),
|
||||
context.getResources().getString(R.string.config_delete_error), file.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,11 +84,13 @@ public final class FileConfigStore implements ConfigStore {
|
||||
final File file = fileFor(name);
|
||||
final File replacementFile = fileFor(replacement);
|
||||
if (!replacementFile.createNewFile())
|
||||
throw new IOException("Configuration for " + replacement + " already exists");
|
||||
throw new IOException(String.format(Locale.getDefault(),
|
||||
context.getResources().getString(R.string.config_exists_error), replacement));
|
||||
if (!file.renameTo(replacementFile)) {
|
||||
if (!replacementFile.delete())
|
||||
Log.w(TAG, "Couldn't delete marker file for new name " + replacement);
|
||||
throw new IOException("Cannot rename configuration file " + file.getName());
|
||||
throw new IOException(String.format(Locale.getDefault(),
|
||||
context.getResources().getString(R.string.config_rename_error), file.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +99,8 @@ public final class FileConfigStore implements ConfigStore {
|
||||
Log.d(TAG, "Saving configuration for tunnel " + name);
|
||||
final File file = fileFor(name);
|
||||
if (!file.isFile())
|
||||
throw new FileNotFoundException("Configuration file " + file.getName() + " not found");
|
||||
throw new FileNotFoundException(String.format(Locale.getDefault(),
|
||||
context.getResources().getString(R.string.config_not_found_error), file.getName()));
|
||||
try (final FileOutputStream stream = new FileOutputStream(file, false)) {
|
||||
stream.write(config.toWgQuickString().getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.wireguard.config.ParseException;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ConfigNamingDialogFragment extends DialogFragment {
|
||||
@@ -68,7 +69,8 @@ public class ConfigNamingDialogFragment extends DialogFragment {
|
||||
try {
|
||||
config = Config.parse(new ByteArrayInputStream(getArguments().getString(KEY_CONFIG_TEXT).getBytes(StandardCharsets.UTF_8)));
|
||||
} catch (final IOException | ParseException exception) {
|
||||
throw new RuntimeException("Invalid config passed to " + getClass().getSimpleName(), exception);
|
||||
throw new RuntimeException(String.format(Locale.getDefault(),
|
||||
getResources().getString(R.string.invalid_config_error), getClass().getSimpleName()), exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
@@ -114,14 +115,15 @@ public class TunnelListFragment extends BaseFragment {
|
||||
int idx = name.lastIndexOf('/');
|
||||
if (idx >= 0) {
|
||||
if (idx >= name.length() - 1)
|
||||
throw new IllegalArgumentException("Illegal file name: " + name);
|
||||
throw new IllegalArgumentException(String.format(Locale.getDefault(),
|
||||
getResources().getString(R.string.illegal_filename_error), name));
|
||||
name = name.substring(idx + 1);
|
||||
}
|
||||
boolean isZip = name.toLowerCase().endsWith(".zip");
|
||||
if (name.toLowerCase().endsWith(".conf"))
|
||||
boolean isZip = name.toLowerCase(Locale.ENGLISH).endsWith(".zip");
|
||||
if (name.toLowerCase(Locale.ENGLISH).endsWith(".conf"))
|
||||
name = name.substring(0, name.length() - ".conf".length());
|
||||
else if (!isZip)
|
||||
throw new IllegalArgumentException("File must be .conf or .zip");
|
||||
throw new IllegalArgumentException(getResources().getString(R.string.bad_extension_error));
|
||||
|
||||
if (isZip) {
|
||||
try (ZipInputStream zip = new ZipInputStream(contentResolver.openInputStream(uri));
|
||||
@@ -137,7 +139,7 @@ public class TunnelListFragment extends BaseFragment {
|
||||
continue;
|
||||
name = name.substring(name.lastIndexOf('/') + 1);
|
||||
}
|
||||
if (name.toLowerCase().endsWith(".conf"))
|
||||
if (name.toLowerCase(Locale.ENGLISH).endsWith(".conf"))
|
||||
name = name.substring(0, name.length() - ".conf".length());
|
||||
else
|
||||
continue;
|
||||
@@ -160,7 +162,7 @@ public class TunnelListFragment extends BaseFragment {
|
||||
if (throwables.size() == 1)
|
||||
throw throwables.get(0);
|
||||
else if (throwables.isEmpty())
|
||||
throw new IllegalArgumentException("No configurations found");
|
||||
throw new IllegalArgumentException(getResources().getString(R.string.no_configs_error));
|
||||
}
|
||||
|
||||
return CompletableFuture.allOf(futureTunnels.toArray(new CompletableFuture[futureTunnels.size()]));
|
||||
|
||||
@@ -44,7 +44,8 @@ public class LogExporterPreference extends Preference {
|
||||
final File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
|
||||
final File file = new File(path, "wireguard-log.txt");
|
||||
if (!path.isDirectory() && !path.mkdirs())
|
||||
throw new IOException("Cannot create output directory");
|
||||
throw new IOException(
|
||||
getContext().getResources().getString(R.string.create_output_dir_error));
|
||||
|
||||
/* We would like to simply run `builder.redirectOutput(file);`, but this is API 26.
|
||||
* Instead we have to do this dance, since logcat appends.
|
||||
|
||||
@@ -17,6 +17,8 @@ import com.wireguard.android.Application;
|
||||
import com.wireguard.android.BuildConfig;
|
||||
import com.wireguard.android.R;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class VersionPreference extends Preference {
|
||||
@Nullable private String versionSummary;
|
||||
|
||||
@@ -24,11 +26,11 @@ public class VersionPreference extends Preference {
|
||||
super(context, attrs);
|
||||
|
||||
Application.getBackendAsync().thenAccept(backend -> {
|
||||
versionSummary = getContext().getString(R.string.version_summary_checking, backend.getTypeName().toLowerCase());
|
||||
versionSummary = getContext().getString(R.string.version_summary_checking, backend.getTypePrettyName().toLowerCase(Locale.ENGLISH));
|
||||
Application.getAsyncWorker().supplyAsync(backend::getVersion).whenComplete((version, exception) -> {
|
||||
versionSummary = exception == null
|
||||
? getContext().getString(R.string.version_summary, backend.getTypeName(), version)
|
||||
: getContext().getString(R.string.version_summary_unknown, backend.getTypeName().toLowerCase());
|
||||
? getContext().getString(R.string.version_summary, backend.getTypePrettyName(), version)
|
||||
: getContext().getString(R.string.version_summary_unknown, backend.getTypePrettyName().toLowerCase(Locale.ENGLISH));
|
||||
notifyChanged();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -55,7 +55,8 @@ public class ZipExporterPreference extends Preference {
|
||||
for (final Tunnel tunnel : tunnels)
|
||||
futureConfigs.add(tunnel.getConfigAsync().toCompletableFuture());
|
||||
if (futureConfigs.isEmpty()) {
|
||||
exportZipComplete(null, new IllegalArgumentException("No tunnels exist"));
|
||||
exportZipComplete(null, new IllegalArgumentException(
|
||||
getContext().getResources().getString(R.string.no_tunnels_error)));
|
||||
return;
|
||||
}
|
||||
CompletableFuture.allOf(futureConfigs.toArray(new CompletableFuture[futureConfigs.size()]))
|
||||
@@ -65,12 +66,13 @@ public class ZipExporterPreference extends Preference {
|
||||
final File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
|
||||
final File file = new File(path, "wireguard-export.zip");
|
||||
if (!path.isDirectory() && !path.mkdirs())
|
||||
throw new IOException("Cannot create output directory");
|
||||
throw new IOException(
|
||||
getContext().getResources().getString(R.string.create_output_dir_error));
|
||||
try (ZipOutputStream zip = new ZipOutputStream(new FileOutputStream(file))) {
|
||||
for (int i = 0; i < futureConfigs.size(); ++i) {
|
||||
zip.putNextEntry(new ZipEntry(tunnels.get(i).getName() + ".conf"));
|
||||
zip.write(futureConfigs.get(i).getNow(null).
|
||||
toString().getBytes(StandardCharsets.UTF_8));
|
||||
toWgQuickString().getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
zip.closeEntry();
|
||||
} catch (final Exception e) {
|
||||
|
||||
@@ -66,7 +66,7 @@ public enum ExceptionLoggers implements BiConsumer<Object, Throwable> {
|
||||
message = null;
|
||||
}
|
||||
} else {
|
||||
message = throwable.getMessage();
|
||||
message = innerThrowable.getMessage();
|
||||
}
|
||||
return message != null ? message : innerThrowable.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@@ -30,6 +31,7 @@ public class RootShell {
|
||||
private static final String SU = "su";
|
||||
private static final String TAG = "WireGuard/" + RootShell.class.getSimpleName();
|
||||
|
||||
private final Context context;
|
||||
private final String deviceNotRootedMessage;
|
||||
private final File localBinaryDir;
|
||||
private final File localTemporaryDir;
|
||||
@@ -47,6 +49,7 @@ public class RootShell {
|
||||
localTemporaryDir = new File(cacheDir, "tmp");
|
||||
preamble = String.format("export CALLING_PACKAGE=%s PATH=\"%s:$PATH\" TMPDIR='%s'; id -u\n",
|
||||
BuildConfig.APPLICATION_ID, localBinaryDir, localTemporaryDir);
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
private static boolean isExecutableInPath(final String name) {
|
||||
@@ -121,9 +124,10 @@ public class RootShell {
|
||||
}
|
||||
}
|
||||
if (markersSeen != 4)
|
||||
throw new IOException("Expected 4 markers, received " + markersSeen);
|
||||
throw new IOException(String.format(Locale.getDefault(),
|
||||
context.getResources().getString(R.string.marker_count_error), markersSeen));
|
||||
if (errnoStdout != errnoStderr)
|
||||
throw new IOException("Unable to read exit status");
|
||||
throw new IOException(context.getResources().getString(R.string.exit_status_read_error));
|
||||
Log.v(TAG, "exit: " + errnoStdout);
|
||||
return errnoStdout;
|
||||
}
|
||||
@@ -136,9 +140,9 @@ public class RootShell {
|
||||
if (isRunning())
|
||||
return;
|
||||
if (!localBinaryDir.isDirectory() && !localBinaryDir.mkdirs())
|
||||
throw new FileNotFoundException("Could not create local binary directory");
|
||||
throw new FileNotFoundException(context.getResources().getString(R.string.create_bin_dir_error));
|
||||
if (!localTemporaryDir.isDirectory() && !localTemporaryDir.mkdirs())
|
||||
throw new FileNotFoundException("Could not create local temporary directory");
|
||||
throw new FileNotFoundException(context.getResources().getString(R.string.create_temp_dir_error));
|
||||
try {
|
||||
final ProcessBuilder builder = new ProcessBuilder().command(SU);
|
||||
builder.environment().put("LC_ALL", "C");
|
||||
@@ -168,7 +172,8 @@ public class RootShell {
|
||||
if (line.contains("Permission denied"))
|
||||
throw new NoRootException(deviceNotRootedMessage);
|
||||
}
|
||||
throw new IOException("Shell failed to start: " + process.exitValue());
|
||||
throw new IOException(String.format(Locale.getDefault(),
|
||||
context.getResources().getString(R.string.shell_start_error), process.exitValue()));
|
||||
}
|
||||
} catch (final IOException | NoRootException e) {
|
||||
stop();
|
||||
|
||||
@@ -12,6 +12,7 @@ import android.util.Log;
|
||||
|
||||
import com.wireguard.android.Application;
|
||||
import com.wireguard.android.BuildConfig;
|
||||
import com.wireguard.android.R;
|
||||
import com.wireguard.android.util.RootShell.NoRootException;
|
||||
|
||||
import java.io.File;
|
||||
@@ -41,6 +42,7 @@ public final class ToolsInstaller {
|
||||
@Nullable private static final File INSTALL_DIR = getInstallDir();
|
||||
private static final String TAG = "WireGuard/" + ToolsInstaller.class.getSimpleName();
|
||||
|
||||
private final Context context;
|
||||
private final File localBinaryDir;
|
||||
private final Object lock = new Object();
|
||||
private final File nativeLibraryDir;
|
||||
@@ -50,6 +52,7 @@ public final class ToolsInstaller {
|
||||
public ToolsInstaller(final Context context) {
|
||||
localBinaryDir = new File(context.getCacheDir(), "bin");
|
||||
nativeLibraryDir = new File(context.getApplicationInfo().nativeLibraryDir);
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -102,7 +105,8 @@ public final class ToolsInstaller {
|
||||
}
|
||||
}
|
||||
if (!areToolsAvailable)
|
||||
throw new FileNotFoundException("Required tools unavailable");
|
||||
throw new FileNotFoundException(
|
||||
context.getResources().getString(R.string.tools_unavailable_error));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -218,7 +218,7 @@ public class FloatingActionsMenu extends ViewGroup {
|
||||
attr.recycle();
|
||||
|
||||
if (mLabelsStyle != 0 && expandsHorizontally()) {
|
||||
throw new IllegalStateException("Action labels in horizontal expand orientation is not supported.");
|
||||
throw new IllegalStateException(getResources().getString(R.string.horizontal_expand_error));
|
||||
}
|
||||
|
||||
createAddButton(context);
|
||||
|
||||
@@ -30,7 +30,9 @@ public final class Config {
|
||||
private final List<Peer> peers;
|
||||
|
||||
private Config(final Builder builder) {
|
||||
interfaze = Objects.requireNonNull(builder.interfaze, "An [Interface] section is required");
|
||||
if (builder.interfaze == null)
|
||||
throw new IllegalArgumentException("An [Interface] section is required");
|
||||
interfaze = builder.interfaze;
|
||||
// Defensively copy to ensure immutability even if the Builder is reused.
|
||||
peers = Collections.unmodifiableList(new ArrayList<>(builder.peers));
|
||||
}
|
||||
|
||||
@@ -44,13 +44,15 @@ public final class InetEndpoint {
|
||||
|
||||
public static InetEndpoint parse(final String endpoint) {
|
||||
if (FORBIDDEN_CHARACTERS.matcher(endpoint).find())
|
||||
throw new IllegalArgumentException("Forbidden characters in Endpoint");
|
||||
throw new IllegalArgumentException("Forbidden characters in endpoint");
|
||||
final URI uri;
|
||||
try {
|
||||
uri = new URI("wg://" + endpoint);
|
||||
} catch (final URISyntaxException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
if (uri.getPort() < 0)
|
||||
throw new IllegalArgumentException("An endpoint must specify a port (e.g. 51820)");
|
||||
try {
|
||||
InetAddresses.parse(uri.getHost());
|
||||
// Parsing ths host as a numeric address worked, so we don't need to do DNS lookups.
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -43,11 +44,14 @@ public final class Interface {
|
||||
private final Optional<Integer> mtu;
|
||||
|
||||
private Interface(final Builder builder) {
|
||||
if (builder.keyPair == null)
|
||||
throw new IllegalArgumentException("Interfaces must have a private key");
|
||||
|
||||
// Defensively copy to ensure immutability even if the Builder is reused.
|
||||
addresses = Collections.unmodifiableSet(new LinkedHashSet<>(builder.addresses));
|
||||
dnsServers = Collections.unmodifiableSet(new LinkedHashSet<>(builder.dnsServers));
|
||||
excludedApplications = Collections.unmodifiableSet(new LinkedHashSet<>(builder.excludedApplications));
|
||||
keyPair = Objects.requireNonNull(builder.keyPair, "Interfaces must have a private key");
|
||||
keyPair = builder.keyPair;
|
||||
listenPort = builder.listenPort;
|
||||
mtu = builder.mtu;
|
||||
}
|
||||
@@ -64,7 +68,7 @@ public final class Interface {
|
||||
for (final CharSequence line : lines) {
|
||||
final Attribute attribute = Attribute.parse(line)
|
||||
.orElseThrow(() -> new ParseException("[Interface]", line, "Syntax error"));
|
||||
switch (attribute.getKey().toLowerCase()) {
|
||||
switch (attribute.getKey().toLowerCase(Locale.ENGLISH)) {
|
||||
case "address":
|
||||
builder.parseAddresses(attribute.getValue());
|
||||
break;
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -34,12 +35,14 @@ public final class Peer {
|
||||
private final Key publicKey;
|
||||
|
||||
private Peer(final Builder builder) {
|
||||
if (builder.publicKey == null)
|
||||
throw new IllegalArgumentException("Peers must have a public key");
|
||||
// Defensively copy to ensure immutability even if the Builder is reused.
|
||||
allowedIps = Collections.unmodifiableSet(new LinkedHashSet<>(builder.allowedIps));
|
||||
endpoint = builder.endpoint;
|
||||
persistentKeepalive = builder.persistentKeepalive;
|
||||
preSharedKey = builder.preSharedKey;
|
||||
publicKey = Objects.requireNonNull(builder.publicKey, "Peers must have a public key");
|
||||
publicKey = builder.publicKey;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,7 +57,7 @@ public final class Peer {
|
||||
for (final CharSequence line : lines) {
|
||||
final Attribute attribute = Attribute.parse(line)
|
||||
.orElseThrow(() -> new ParseException("[Peer]", line, "Syntax error"));
|
||||
switch (attribute.getKey().toLowerCase()) {
|
||||
switch (attribute.getKey().toLowerCase(Locale.ENGLISH)) {
|
||||
case "allowedips":
|
||||
builder.parseAllowedIPs(attribute.getValue());
|
||||
break;
|
||||
|
||||
@@ -20,53 +20,78 @@
|
||||
<item quantity="one">Imported %d tunnel</item>
|
||||
<item quantity="other">Imported %d tunnels</item>
|
||||
</plurals>
|
||||
<plurals name="set_excluded_applications">
|
||||
<item quantity="one">%d Excluded Application</item>
|
||||
<item quantity="other">%d Excluded Applications</item>
|
||||
</plurals>
|
||||
<string name="add_peer">Add peer</string>
|
||||
<string name="addresses">Addresses</string>
|
||||
<string name="allowed_ips">Allowed IPs</string>
|
||||
<string name="app_name">WireGuard</string>
|
||||
<string name="bad_extension_error">File must be .conf or .zip</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="config_delete_error">Cannot delete configuration file %s</string>
|
||||
<string name="config_exists_error">Configuration for %s already exists</string>
|
||||
<string name="config_file_exists_error">Configuration file %s already exists</string>
|
||||
<string name="config_not_found_error">Configuration file %s not found</string>
|
||||
<string name="config_rename_error">Cannot rename configuration file %s</string>
|
||||
<string name="config_save_error">Unable to save configuration for “%1$s”: %2$s</string>
|
||||
<string name="config_save_success">Successfully saved configuration for “%s”</string>
|
||||
<string name="create_activity_title">Create WireGuard Tunnel</string>
|
||||
<string name="create_bin_dir_error">Could not create local binary directory</string>
|
||||
<string name="create_empty">Create from scratch</string>
|
||||
<string name="create_from_file">Create from file or archive</string>
|
||||
<string name="create_from_qrcode">Create from QR code</string>
|
||||
<string name="create_output_dir_error">Cannot create output directory</string>
|
||||
<string name="create_temp_dir_error">Could not create local temporary directory</string>
|
||||
<string name="create_tunnel">Create Tunnel</string>
|
||||
<string name="dark_theme_title">Use dark theme</string>
|
||||
<string name="dark_theme_summary_on">Currently using dark night theme</string>
|
||||
<string name="dark_theme_summary_off">Currently using light day theme</string>
|
||||
<string name="dark_theme_summary_on">Currently using dark night theme</string>
|
||||
<string name="dark_theme_title">Use dark theme</string>
|
||||
<string name="delete">Delete</string>
|
||||
<string name="deselect_all">Deselect All</string>
|
||||
<string name="select_all">Select all</string>
|
||||
<string name="dns_servers">DNS servers</string>
|
||||
<string name="edit">Edit</string>
|
||||
<string name="endpoint">Endpoint</string>
|
||||
<string name="error_fetching_apps">Error fetching apps list: %s</string>
|
||||
<string name="error_down">Error bringing down tunnel: %s</string>
|
||||
<string name="error_fetching_apps">Error fetching apps list: %s</string>
|
||||
<string name="error_root">Please obtain root access and try again</string>
|
||||
<string name="error_up">Error bringing up tunnel: %s</string>
|
||||
<string name="excluded_applications">Excluded Applications</string>
|
||||
<string name="exclude_private_ips">Exclude private IPs</string>
|
||||
<string name="excluded_applications">Excluded Applications</string>
|
||||
<string name="exit_status_read_error">Unable to read exit status</string>
|
||||
<string name="generate">Generate</string>
|
||||
<string name="hint_automatic">(auto)</string>
|
||||
<string name="hint_generated">(generated)</string>
|
||||
<string name="hint_optional">(optional)</string>
|
||||
<string name="hint_random">(random)</string>
|
||||
<string name="import_from_qrcode">Import Tunnel from QR Code</string>
|
||||
<string name="horizontal_expand_error">Action labels in horizontal expand orientation is not supported.</string>
|
||||
<string name="illegal_filename_error">Illegal file name %s</string>
|
||||
<string name="import_error">Unable to import tunnel: %s</string>
|
||||
<string name="import_from_qrcode">Import Tunnel from QR Code</string>
|
||||
<string name="import_success">Imported “%s”</string>
|
||||
<string name="interface_title">Interface</string>
|
||||
<string name="invalid_config_error">Invalid config passed to %s</string>
|
||||
<string name="key_length_base64_exception_message">WireGuard base64 keys must be 44 characters encoding 32 bytes</string>
|
||||
<string name="key_length_exception_message">WireGuard keys must be 32 bytes</string>
|
||||
<string name="key_length_hex_exception_message">WireGuard hex keys must be 64 characters encoding 32 bytes</string>
|
||||
<string name="listen_port">Listen port</string>
|
||||
<string name="log_exporter_title">Export log file</string>
|
||||
<string name="log_export_error">Unable to export log: %s</string>
|
||||
<string name="log_export_success">Saved to %s</string>
|
||||
<string name="log_export_summary">Log file will be saved to downloads folder</string>
|
||||
<string name="log_exporter_title">Export log file</string>
|
||||
<string name="marker_count_error">Expected 4 markers, received %i</string>
|
||||
<string name="module_version_error">Unable to determine kernel module version</string>
|
||||
<string name="mtu">MTU</string>
|
||||
<string name="multiple_tunnels_error">Only one userspace tunnel can run at a time</string>
|
||||
<string name="name">Name</string>
|
||||
<string name="parse_error">Cannot parse “%s” at %s</string>
|
||||
<string name="no_config_error">Trying to bring up a tunnel with no config</string>
|
||||
<string name="no_configs_error">No configurations found</string>
|
||||
<string name="no_tunnels_error">No tunnels exist</string>
|
||||
<string name="parse_error">Cannot parse “%1$s” at %2$s</string>
|
||||
<string name="peer">Peer</string>
|
||||
<string name="permission_label">control WireGuard tunnels</string>
|
||||
<string name="permission_description">Allows an app to control WireGuard tunnels. Apps with this permission may enable and disable WireGuard tunnels at will, potentially misdirecting Internet traffic.</string>
|
||||
<string name="permission_label">control WireGuard tunnels</string>
|
||||
<string name="persistent_keepalive">Persistent keepalive</string>
|
||||
<string name="pre_shared_key">Pre-shared key</string>
|
||||
<string name="private_key">Private key</string>
|
||||
@@ -76,42 +101,45 @@
|
||||
<string name="restore_on_boot_summary">Bring up previously-enabled tunnels on boot</string>
|
||||
<string name="restore_on_boot_title">Restore on boot</string>
|
||||
<string name="save">Save</string>
|
||||
<plurals name="set_excluded_applications">
|
||||
<item quantity="one">%d Excluded Application</item>
|
||||
<item quantity="other">%d Excluded Applications</item>
|
||||
</plurals>
|
||||
<string name="select_all">Select all</string>
|
||||
<string name="set_exclusions">Set Exclusions</string>
|
||||
<string name="settings">Settings</string>
|
||||
<string name="shell_start_error">Shell failed to start: %i</string>
|
||||
<string name="toggle_error">Error toggling WireGuard tunnel: %s</string>
|
||||
<string name="tools_installer_already">wg and wg-quick are already installed</string>
|
||||
<string name="tools_installer_failure">Unable to install command-line tools (no root?)</string>
|
||||
<string name="tools_installer_initial">Install optional tools for scripting</string>
|
||||
<string name="tools_installer_working">Installing wg and wg-quick</string>
|
||||
<string name="tools_installer_initial_system">Install optional tools for scripting into the system partition</string>
|
||||
<string name="tools_installer_initial_magisk">Install optional tools for scripting as Magisk module</string>
|
||||
<string name="tools_installer_success_system">wg and wg-quick installed into the system partition</string>
|
||||
<string name="tools_installer_initial_system">Install optional tools for scripting into the system partition</string>
|
||||
<string name="tools_installer_success_magisk">wg and wg-quick installed as a Magisk module (reboot required)</string>
|
||||
<string name="tools_installer_success_system">wg and wg-quick installed into the system partition</string>
|
||||
<string name="tools_installer_title">Install command line tools</string>
|
||||
<string name="tools_installer_working">Installing wg and wg-quick</string>
|
||||
<string name="tools_unavailable_error">Required tools unavailable</string>
|
||||
<string name="tun_create_error">Unable to create tun device</string>
|
||||
<string name="tunnel_config_error">Unable to configure tunnel (wg-quick returned %i)</string>
|
||||
<string name="tunnel_create_error">Unable to create tunnel: %s</string>
|
||||
<string name="tunnel_create_success">Successfully created tunnel “%s”</string>
|
||||
<string name="tunnel_list_placeholder">Add a tunnel using the blue button</string>
|
||||
<string name="tunnel_name">Tunnel Name</string>
|
||||
<string name="tunnel_rename_error">Unable to rename tunnel: %s</string>
|
||||
<string name="tunnel_rename_success">Successfully renamed tunnel to “%s”</string>
|
||||
<string name="tunnel_error_invalid_name">Invalid name</string>
|
||||
<string name="tunnel_error_already_exists">Tunnel %s already exists</string>
|
||||
<string name="tunnel_error_empty_interface_address">Address is empty</string>
|
||||
<string name="tunnel_error_forbidden_endpoint_chars">Forbidden characters in endpoint</string>
|
||||
<string name="tunnel_error_empty_peer_public_key">Peer public key may not be empty</string>
|
||||
<string name="key_length_base64_exception_message">WireGuard base64 keys must be 44 characters encoding 32 bytes</string>
|
||||
<string name="key_length_exception_message">WireGuard keys must be 32 bytes</string>
|
||||
<string name="key_length_hex_exception_message">WireGuard hex keys must be 64 characters encoding 32 bytes</string>
|
||||
<string name="version_title">WireGuard for Android v%s"</string>
|
||||
<string name="tunnel_error_forbidden_endpoint_chars">Forbidden characters in endpoint</string>
|
||||
<string name="tunnel_error_invalid_name">Invalid name</string>
|
||||
<string name="tunnel_list_placeholder">Add a tunnel using the blue button</string>
|
||||
<string name="tunnel_name">Tunnel Name</string>
|
||||
<string name="tunnel_on_error">Unable to turn tunnel on (wgTurnOn returned %i)</string>
|
||||
<string name="tunnel_rename_error">Unable to rename tunnel: %s</string>
|
||||
<string name="tunnel_rename_success">Successfully renamed tunnel to “%s”</string>
|
||||
<string name="type_name_go_userspace">Go userspace</string>
|
||||
<string name="type_name_kernel_module">Kernel module</string>
|
||||
<string name="version_summary">%1$s backend v%2$s</string>
|
||||
<string name="version_summary_checking">Checking %s backend version</string>
|
||||
<string name="version_summary_unknown">Unknown %s version</string>
|
||||
<string name="zip_exporter_title">Export tunnels to zip file</string>
|
||||
<string name="version_title">WireGuard for Android v%s"</string>
|
||||
<string name="vpn_not_authed_error">VPN service not authorized by user</string>
|
||||
<string name="vpn_start_error">Unable to start Android VPN service</string>
|
||||
<string name="zip_export_error">Unable to export tunnels: %s</string>
|
||||
<string name="zip_export_success">Saved to %s</string>
|
||||
<string name="zip_export_summary">Zip file will be saved to downloads folder</string>
|
||||
<string name="zip_exporter_title">Export tunnels to zip file</string>
|
||||
</resources>
|
||||
|
||||
@@ -27,7 +27,7 @@ default: $(DESTDIR)/libwg-go.so
|
||||
|
||||
GOBUILDARCH := $(NDK_GO_ARCH_MAP_$(shell uname -m))
|
||||
GOBUILDOS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
|
||||
GOBUILDVERSION := 1.11.1
|
||||
GOBUILDVERSION := 1.11.2
|
||||
GOBUILDTARBALL := https://dl.google.com/go/go$(GOBUILDVERSION).$(GOBUILDOS)-$(GOBUILDARCH).tar.gz
|
||||
GOBUILDVERSION_NEEDED := go version go$(GOBUILDVERSION) $(GOBUILDOS)/$(GOBUILDARCH)
|
||||
export GOROOT := $(BUILDDIR)/goroot
|
||||
@@ -41,7 +41,7 @@ $(GOROOT)/bin/go:
|
||||
rm -rf "$(GOROOT)"
|
||||
mkdir -p "$(GOROOT)"
|
||||
curl "$(GOBUILDTARBALL)" | tar -C "$(GOROOT)" --strip-components=1 -xzf - || { rm -rf "$(GOROOT)"; exit 1; }
|
||||
patch -p1 -f -N -r- -d "$(GOROOT)" < goruntime-boottime-over-monotonic.diff || { rm -rf "$(GOROOT)"; exit 1; }
|
||||
cat goruntime-*.diff | patch -p1 -f -N -r- -d "$(GOROOT)" || { rm -rf "$(GOROOT)"; exit 1; }
|
||||
|
||||
$(shell test "$$(cat .gobuildversion 2>/dev/null)" = "$(GOBUILDVERSION_CURRENT)" || rm -f "$(DESTDIR)/libwg-go.so")
|
||||
|
||||
|
||||
@@ -0,0 +1,291 @@
|
||||
diff --git a/src/syscall/syscall_linux_386.go b/src/syscall/syscall_linux_386.go
|
||||
index 49db72450f..6e162ebb41 100644
|
||||
--- a/src/syscall/syscall_linux_386.go
|
||||
+++ b/src/syscall/syscall_linux_386.go
|
||||
@@ -62,8 +62,6 @@ func Pipe2(p []int, flags int) (err error) {
|
||||
//sysnb InotifyInit() (fd int, err error)
|
||||
//sys Ioperm(from int, num int, on int) (err error)
|
||||
//sys Iopl(level int) (err error)
|
||||
-//sys Lchown(path string, uid int, gid int) (err error) = SYS_LCHOWN32
|
||||
-//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
|
||||
//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
|
||||
//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
|
||||
//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64
|
||||
@@ -74,7 +72,6 @@ func Pipe2(p []int, flags int) (err error) {
|
||||
//sysnb Setresuid(ruid int, euid int, suid int) (err error) = SYS_SETRESUID32
|
||||
//sysnb Setreuid(ruid int, euid int) (err error) = SYS_SETREUID32
|
||||
//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error)
|
||||
-//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
|
||||
//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
|
||||
//sys Truncate(path string, length int64) (err error) = SYS_TRUNCATE64
|
||||
//sysnb getgroups(n int, list *_Gid_t) (nn int, err error) = SYS_GETGROUPS32
|
||||
@@ -84,6 +81,18 @@ func Pipe2(p []int, flags int) (err error) {
|
||||
//sys mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error)
|
||||
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
|
||||
|
||||
+func Stat(path string, stat *Stat_t) (err error) {
|
||||
+ return fstatat(_AT_FDCWD, path, stat, 0)
|
||||
+}
|
||||
+
|
||||
+func Lchown(path string, uid int, gid int) (err error) {
|
||||
+ return Fchownat(_AT_FDCWD, path, uid, gid, _AT_SYMLINK_NOFOLLOW)
|
||||
+}
|
||||
+
|
||||
+func Lstat(path string, stat *Stat_t) (err error) {
|
||||
+ return fstatat(_AT_FDCWD, path, stat, _AT_SYMLINK_NOFOLLOW)
|
||||
+}
|
||||
+
|
||||
func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
|
||||
page := uintptr(offset / 4096)
|
||||
if offset != int64(page)*4096 {
|
||||
diff --git a/src/syscall/syscall_linux_amd64.go b/src/syscall/syscall_linux_amd64.go
|
||||
index 1a21d9db6f..f740ab4e72 100644
|
||||
--- a/src/syscall/syscall_linux_amd64.go
|
||||
+++ b/src/syscall/syscall_linux_amd64.go
|
||||
@@ -22,9 +22,7 @@ const (
|
||||
//sysnb InotifyInit() (fd int, err error)
|
||||
//sys Ioperm(from int, num int, on int) (err error)
|
||||
//sys Iopl(level int) (err error)
|
||||
-//sys Lchown(path string, uid int, gid int) (err error)
|
||||
//sys Listen(s int, n int) (err error)
|
||||
-//sys Lstat(path string, stat *Stat_t) (err error)
|
||||
//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
|
||||
//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
|
||||
//sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
|
||||
@@ -66,6 +64,14 @@ func Stat(path string, stat *Stat_t) (err error) {
|
||||
return fstatat(_AT_FDCWD, path, stat, 0)
|
||||
}
|
||||
|
||||
+func Lchown(path string, uid int, gid int) (err error) {
|
||||
+ return Fchownat(_AT_FDCWD, path, uid, gid, _AT_SYMLINK_NOFOLLOW)
|
||||
+}
|
||||
+
|
||||
+func Lstat(path string, stat *Stat_t) (err error) {
|
||||
+ return fstatat(_AT_FDCWD, path, stat, _AT_SYMLINK_NOFOLLOW)
|
||||
+}
|
||||
+
|
||||
//go:noescape
|
||||
func gettimeofday(tv *Timeval) (err Errno)
|
||||
|
||||
diff --git a/src/syscall/syscall_linux_arm.go b/src/syscall/syscall_linux_arm.go
|
||||
index b0c0ac7c4f..65543193e1 100644
|
||||
--- a/src/syscall/syscall_linux_arm.go
|
||||
+++ b/src/syscall/syscall_linux_arm.go
|
||||
@@ -83,9 +83,7 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
|
||||
//sysnb Getgid() (gid int) = SYS_GETGID32
|
||||
//sysnb Getuid() (uid int) = SYS_GETUID32
|
||||
//sysnb InotifyInit() (fd int, err error)
|
||||
-//sys Lchown(path string, uid int, gid int) (err error) = SYS_LCHOWN32
|
||||
//sys Listen(s int, n int) (err error)
|
||||
-//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
|
||||
//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64
|
||||
//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT
|
||||
//sys Setfsgid(gid int) (err error) = SYS_SETFSGID32
|
||||
@@ -96,7 +94,6 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
|
||||
//sysnb Setreuid(ruid int, euid int) (err error) = SYS_SETREUID32
|
||||
//sys Shutdown(fd int, how int) (err error)
|
||||
//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error)
|
||||
-//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
|
||||
|
||||
// Vsyscalls on amd64.
|
||||
//sysnb Gettimeofday(tv *Timeval) (err error)
|
||||
@@ -110,6 +107,18 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
|
||||
//sys mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error)
|
||||
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
|
||||
|
||||
+func Stat(path string, stat *Stat_t) (err error) {
|
||||
+ return fstatat(_AT_FDCWD, path, stat, 0)
|
||||
+}
|
||||
+
|
||||
+func Lchown(path string, uid int, gid int) (err error) {
|
||||
+ return Fchownat(_AT_FDCWD, path, uid, gid, _AT_SYMLINK_NOFOLLOW)
|
||||
+}
|
||||
+
|
||||
+func Lstat(path string, stat *Stat_t) (err error) {
|
||||
+ return fstatat(_AT_FDCWD, path, stat, _AT_SYMLINK_NOFOLLOW)
|
||||
+}
|
||||
+
|
||||
func Fstatfs(fd int, buf *Statfs_t) (err error) {
|
||||
_, _, e := Syscall(SYS_FSTATFS64, uintptr(fd), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf)))
|
||||
if e != 0 {
|
||||
diff --git a/src/syscall/zsyscall_linux_386.go b/src/syscall/zsyscall_linux_386.go
|
||||
index 62827f16dc..0882494c47 100644
|
||||
--- a/src/syscall/zsyscall_linux_386.go
|
||||
+++ b/src/syscall/zsyscall_linux_386.go
|
||||
@@ -1276,36 +1276,6 @@ func Iopl(level int) (err error) {
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
-func Lchown(path string, uid int, gid int) (err error) {
|
||||
- var _p0 *byte
|
||||
- _p0, err = BytePtrFromString(path)
|
||||
- if err != nil {
|
||||
- return
|
||||
- }
|
||||
- _, _, e1 := Syscall(SYS_LCHOWN32, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
|
||||
- if e1 != 0 {
|
||||
- err = errnoErr(e1)
|
||||
- }
|
||||
- return
|
||||
-}
|
||||
-
|
||||
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
-
|
||||
-func Lstat(path string, stat *Stat_t) (err error) {
|
||||
- var _p0 *byte
|
||||
- _p0, err = BytePtrFromString(path)
|
||||
- if err != nil {
|
||||
- return
|
||||
- }
|
||||
- _, _, e1 := Syscall(SYS_LSTAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
|
||||
- if e1 != 0 {
|
||||
- err = errnoErr(e1)
|
||||
- }
|
||||
- return
|
||||
-}
|
||||
-
|
||||
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
-
|
||||
func Pread(fd int, p []byte, offset int64) (n int, err error) {
|
||||
var _p0 unsafe.Pointer
|
||||
if len(p) > 0 {
|
||||
@@ -1422,21 +1392,6 @@ func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n i
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
-func Stat(path string, stat *Stat_t) (err error) {
|
||||
- var _p0 *byte
|
||||
- _p0, err = BytePtrFromString(path)
|
||||
- if err != nil {
|
||||
- return
|
||||
- }
|
||||
- _, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
|
||||
- if e1 != 0 {
|
||||
- err = errnoErr(e1)
|
||||
- }
|
||||
- return
|
||||
-}
|
||||
-
|
||||
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
-
|
||||
func SyncFileRange(fd int, off int64, n int64, flags int) (err error) {
|
||||
_, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(off>>32), uintptr(n), uintptr(n>>32), uintptr(flags))
|
||||
if e1 != 0 {
|
||||
diff --git a/src/syscall/zsyscall_linux_amd64.go b/src/syscall/zsyscall_linux_amd64.go
|
||||
index b6638269be..9f2046bf93 100644
|
||||
--- a/src/syscall/zsyscall_linux_amd64.go
|
||||
+++ b/src/syscall/zsyscall_linux_amd64.go
|
||||
@@ -1261,21 +1261,6 @@ func Iopl(level int) (err error) {
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
-func Lchown(path string, uid int, gid int) (err error) {
|
||||
- var _p0 *byte
|
||||
- _p0, err = BytePtrFromString(path)
|
||||
- if err != nil {
|
||||
- return
|
||||
- }
|
||||
- _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
|
||||
- if e1 != 0 {
|
||||
- err = errnoErr(e1)
|
||||
- }
|
||||
- return
|
||||
-}
|
||||
-
|
||||
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
-
|
||||
func Listen(s int, n int) (err error) {
|
||||
_, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0)
|
||||
if e1 != 0 {
|
||||
@@ -1286,21 +1271,6 @@ func Listen(s int, n int) (err error) {
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
-func Lstat(path string, stat *Stat_t) (err error) {
|
||||
- var _p0 *byte
|
||||
- _p0, err = BytePtrFromString(path)
|
||||
- if err != nil {
|
||||
- return
|
||||
- }
|
||||
- _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
|
||||
- if e1 != 0 {
|
||||
- err = errnoErr(e1)
|
||||
- }
|
||||
- return
|
||||
-}
|
||||
-
|
||||
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
-
|
||||
func Pread(fd int, p []byte, offset int64) (n int, err error) {
|
||||
var _p0 unsafe.Pointer
|
||||
if len(p) > 0 {
|
||||
diff --git a/src/syscall/zsyscall_linux_arm.go b/src/syscall/zsyscall_linux_arm.go
|
||||
index bb20d6e946..3d099aa16d 100644
|
||||
--- a/src/syscall/zsyscall_linux_arm.go
|
||||
+++ b/src/syscall/zsyscall_linux_arm.go
|
||||
@@ -1415,21 +1415,6 @@ func InotifyInit() (fd int, err error) {
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
-func Lchown(path string, uid int, gid int) (err error) {
|
||||
- var _p0 *byte
|
||||
- _p0, err = BytePtrFromString(path)
|
||||
- if err != nil {
|
||||
- return
|
||||
- }
|
||||
- _, _, e1 := Syscall(SYS_LCHOWN32, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
|
||||
- if e1 != 0 {
|
||||
- err = errnoErr(e1)
|
||||
- }
|
||||
- return
|
||||
-}
|
||||
-
|
||||
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
-
|
||||
func Listen(s int, n int) (err error) {
|
||||
_, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0)
|
||||
if e1 != 0 {
|
||||
@@ -1440,21 +1425,6 @@ func Listen(s int, n int) (err error) {
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
-func Lstat(path string, stat *Stat_t) (err error) {
|
||||
- var _p0 *byte
|
||||
- _p0, err = BytePtrFromString(path)
|
||||
- if err != nil {
|
||||
- return
|
||||
- }
|
||||
- _, _, e1 := Syscall(SYS_LSTAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
|
||||
- if e1 != 0 {
|
||||
- err = errnoErr(e1)
|
||||
- }
|
||||
- return
|
||||
-}
|
||||
-
|
||||
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
-
|
||||
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||
r0, _, e1 := Syscall6(SYS_SENDFILE64, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0)
|
||||
written = int(r0)
|
||||
@@ -1558,21 +1528,6 @@ func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n i
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
-func Stat(path string, stat *Stat_t) (err error) {
|
||||
- var _p0 *byte
|
||||
- _p0, err = BytePtrFromString(path)
|
||||
- if err != nil {
|
||||
- return
|
||||
- }
|
||||
- _, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
|
||||
- if e1 != 0 {
|
||||
- err = errnoErr(e1)
|
||||
- }
|
||||
- return
|
||||
-}
|
||||
-
|
||||
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
-
|
||||
func Gettimeofday(tv *Timeval) (err error) {
|
||||
_, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
|
||||
if e1 != 0 {
|
||||
+1
-1
Submodule app/tools/wireguard-go updated: b803276061...5ace0fdfe2
Reference in New Issue
Block a user