Merge remote-tracking branch 'origin/master'

pull/58/head^2
Jeff Becker 6 years ago
commit a8e3f79fc4
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

4
.gitignore vendored

@ -43,4 +43,6 @@ lokinet.exe
rapidjson/ rapidjson/
.gradle/ .gradle/
.idea
.vscode

@ -1,19 +0,0 @@
<component name="ArtifactManager">
<artifact type="apk" name="loki-network">
<output-path>$PROJECT_DIR$/android/build/artifacts/loki_network</output-path>
<properties id="android-properties">
<options>
<option name="keyStoreUrl" value="file://" />
<option name="proGuardCfgFiles">
<list>
<option value="file://%MODULE_SDK_HOME%/tools/proguard/proguard-android.txt" />
</list>
</option>
<option name="signingMode" value="DEBUG" />
</options>
</properties>
<root id="archive" name="loki-network.apk">
<element id="file-copy" path="$PROJECT_DIR$/android/build/outputs/apk/lokinet-debug.apk" />
</root>
</artifact>
</component>

@ -1,29 +0,0 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<Objective-C-extensions>
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cpp" header="h" fileNamingConvention="NONE" />
<pair source="c" header="h" fileNamingConvention="NONE" />
</extensions>
</Objective-C-extensions>
</code_scheme>
</component>

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android" name="Android">
<configuration>
<option name="GEN_FOLDER_RELATIVE_PATH_APT" value="/../android/gen" />
<option name="GEN_FOLDER_RELATIVE_PATH_AIDL" value="/../android/gen" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/../android/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/../android/res" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/../android/assets" />
<option name="LIBS_FOLDER_RELATIVE_PATH" value="/../android/libs" />
<option name="APK_PATH" value="/../android/build/outputs/apk/lokinet-debug.apk" />
<option name="PACK_TEST_CODE" value="true" />
<option name="PROGUARD_LOGS_FOLDER_RELATIVE_PATH" value="/../proguard_logs" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/android/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/android/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/android/gen" isTestSource="false" generated="true" />
</content>
<orderEntry type="jdk" jdkName="Android API 27 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="7">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
<item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="6">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_9" default="false" project-jdk-name="Android API 28 Platform" project-jdk-type="Android SDK">
<output url="file://$PROJECT_DIR$/android/build" />
</component>
</project>

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/loki-network.iml" filepath="$PROJECT_DIR$/.idea/loki-network.iml" />
</modules>
</component>
</project>

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

@ -1,560 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AndroidLayouts">
<shared>
<config />
</shared>
</component>
<component name="AndroidLogFilters">
<option name="TOOL_WINDOW_CUSTOM_FILTER" value="loki" />
<option name="TOOL_WINDOW_CONFIGURED_FILTER" value="No Filters" />
</component>
<component name="CMakeSettings">
<configurations>
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
</configurations>
</component>
<component name="ChangeListManager">
<list default="true" id="3ea80a95-2a4c-454e-b230-b4c8c2b78759" name="Default" comment="">
<change afterPath="$PROJECT_DIR$/.idea/artifacts/loki_network.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Makefile" beforeDir="false" afterPath="$PROJECT_DIR$/Makefile" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/AndroidManifest.xml" beforeDir="false" afterPath="$PROJECT_DIR$/android/AndroidManifest.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/res/menu/options_main.xml" beforeDir="false" afterPath="$PROJECT_DIR$/android/res/menu/options_main.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/res/values/strings.xml" beforeDir="false" afterPath="$PROJECT_DIR$/android/res/values/strings.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/src/network/loki/lokinet/LokiNetActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/network/loki/lokinet/LokiNetActivity.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/llarp/android/ifaddrs.c" beforeDir="false" afterPath="$PROJECT_DIR$/llarp/android/ifaddrs.c" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FavoritesManager">
<favorites_list name="loki-network" />
</component>
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="LokiNetActivity.java" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/android/src/network/loki/lokinet/LokiNetActivity.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1249">
<caret line="128" column="24" selection-start-line="128" selection-start-column="24" selection-end-line="128" selection-end-column="24" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="ForegroundService.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/android/src/network/loki/lokinet/ForegroundService.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="75">
<caret line="5" column="25" selection-start-line="5" selection-start-column="25" selection-end-line="5" selection-end-column="25" />
<folding>
<element signature="e#188#189#0" expanded="true" />
<element signature="e#236#237#0" expanded="true" />
<element signature="e#476#477#0" expanded="true" />
<element signature="e#515#516#0" expanded="true" />
<element signature="e#379#380#0" expanded="true" />
<element signature="e#419#420#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="options_main.xml" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/android/res/menu/options_main.xml">
<provider editor-type-id="android-designer2">
<state />
</provider>
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="225">
<caret line="15" column="7" selection-start-line="15" selection-start-column="7" selection-end-line="15" selection-end-column="7" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="strings.xml" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/android/res/values/strings.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="225">
<caret line="15" selection-start-line="15" selection-end-line="15" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="PermsAskerActivity.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/android/src/network/loki/lokinet/PermsAskerActivity.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1695">
<caret line="124" column="17" selection-start-line="124" selection-start-column="17" selection-end-line="124" selection-end-column="17" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="PermsExplanationActivity.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/android/src/network/loki/lokinet/PermsExplanationActivity.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="255">
<caret line="24" column="5" selection-start-line="24" selection-start-column="5" selection-end-line="24" selection-end-column="5" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="AndroidManifest.xml" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/android/AndroidManifest.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="409">
<caret line="43" column="31" selection-start-line="43" selection-start-column="31" selection-end-line="43" selection-end-column="31" />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/android/AndroidManifest.xml" />
<option value="$PROJECT_DIR$/android/res/menu/options_main.xml" />
<option value="$PROJECT_DIR$/android/src/network/loki/lokinet/ForgroundService.java" />
<option value="$PROJECT_DIR$/android/src/network/loki/lokinet/ForegroundService.java" />
<option value="$PROJECT_DIR$/android/res/values/strings.xml" />
<option value="$PROJECT_DIR$/android/src/network/loki/lokinet/LokiNetActivity.java" />
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="1922" />
<option name="y" value="25" />
<option name="width" value="1916" />
<option name="height" value="1030" />
</component>
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="loki-network" type="b2602c69:ProjectViewProjectNode" />
<item name="loki-network" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="loki-network" type="b2602c69:ProjectViewProjectNode" />
<item name="loki-network" type="462c0819:PsiDirectoryNode" />
<item name="android" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="loki-network" type="b2602c69:ProjectViewProjectNode" />
<item name="loki-network" type="462c0819:PsiDirectoryNode" />
<item name="android" type="462c0819:PsiDirectoryNode" />
<item name="res" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="loki-network" type="b2602c69:ProjectViewProjectNode" />
<item name="loki-network" type="462c0819:PsiDirectoryNode" />
<item name="android" type="462c0819:PsiDirectoryNode" />
<item name="res" type="462c0819:PsiDirectoryNode" />
<item name="menu" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="loki-network" type="b2602c69:ProjectViewProjectNode" />
<item name="loki-network" type="462c0819:PsiDirectoryNode" />
<item name="android" type="462c0819:PsiDirectoryNode" />
<item name="res" type="462c0819:PsiDirectoryNode" />
<item name="values" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="loki-network" type="b2602c69:ProjectViewProjectNode" />
<item name="loki-network" type="462c0819:PsiDirectoryNode" />
<item name="android" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="loki-network" type="b2602c69:ProjectViewProjectNode" />
<item name="loki-network" type="462c0819:PsiDirectoryNode" />
<item name="android" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="lokinet" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="Scope" />
<pane id="PackagesPane" />
<pane id="AndroidView">
<subPane>
<expand>
<path>
<item name="loki-network" type="1abcf292:AndroidViewProjectNode" />
<item name="loki-network" type="e9137016:NonAndroidModuleNode" />
</path>
</expand>
<select />
</subPane>
</pane>
</panes>
</component>
<component name="PropertiesComponent">
<property name="android.sdk.path" value="$USER_HOME$/Android/Sdk" />
<property name="device.picker.selection" value="LGLS676e922dc4e" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/android/build/outputs/apk/lokinet-debug.apk" />
<property name="project.structure.last.edited" value="Artifacts" />
<property name="project.structure.proportion" value="0.15527344" />
<property name="project.structure.side.proportion" value="0.2" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager">
<configuration default="true" type="AndroidJUnit" factoryName="Android JUnit">
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<patterns />
</configuration>
<configuration name="lokinet-android" type="AndroidRunConfigurationType" factoryName="Android App" activateToolWindowBeforeRun="false">
<module name="loki-network" />
<option name="DEPLOY" value="true" />
<option name="DEPLOY_APK_FROM_BUNDLE" value="false" />
<option name="ARTIFACT_NAME" value="" />
<option name="PM_INSTALL_OPTIONS" value="" />
<option name="DYNAMIC_FEATURES_DISABLED_LIST" value="" />
<option name="ACTIVITY_EXTRA_FLAGS" value="" />
<option name="MODE" value="default_activity" />
<option name="CLEAR_LOGCAT" value="false" />
<option name="SHOW_LOGCAT_AUTOMATICALLY" value="true" />
<option name="SKIP_NOOP_APK_INSTALLATIONS" value="true" />
<option name="FORCE_STOP_RUNNING_APP" value="true" />
<option name="TARGET_SELECTION_MODE" value="SHOW_DIALOG" />
<option name="USE_LAST_SELECTED_DEVICE" value="false" />
<option name="PREFERRED_AVD" value="" />
<option name="SELECTED_CLOUD_MATRIX_CONFIGURATION_ID" value="-1" />
<option name="SELECTED_CLOUD_MATRIX_PROJECT_ID" value="" />
<option name="DEBUGGER_TYPE" value="Hybrid" />
<Auto>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
</Auto>
<Hybrid>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
</Hybrid>
<Java />
<Native>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
</Native>
<Profilers>
<option name="ADVANCED_PROFILING_ENABLED" value="false" />
<option name="STARTUP_CPU_PROFILING_ENABLED" value="false" />
<option name="STARTUP_CPU_PROFILING_CONFIGURATION_NAME" value="Sampled (Java)" />
</Profilers>
<option name="DEEP_LINK" value="" />
<option name="ACTIVITY_CLASS" value="" />
<method>
<option name="Android.Gradle.BeforeRunTask" enabled="false" />
<option name="ToolBeforeRunTask" enabled="true" actionId="Tool_External Tools_GNU Make" />
</method>
</configuration>
<configuration default="true" type="Application" factoryName="Application">
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
</configuration>
<configuration default="true" type="TestNG" factoryName="TestNG">
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="SUITE_NAME" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="GROUP_NAME" />
<option name="TEST_OBJECT" value="CLASS" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
<option name="OUTPUT_DIRECTORY" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<option name="USE_DEFAULT_REPORTERS" value="false" />
<option name="PROPERTIES_FILE" />
<properties />
<listeners />
</configuration>
<configuration name="&lt;template&gt;" type="JUnit" default="true" selected="false">
<option name="VM_PARAMETERS" value="-ea" />
<option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
</configuration>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="3ea80a95-2a4c-454e-b230-b4c8c2b78759" name="Default" comment="" />
<created>1541522484586</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1541522484586</updated>
</task>
<servers />
</component>
<component name="TodoView">
<todo-panel id="selected-file">
<is-autoscroll-to-source value="true" />
</todo-panel>
<todo-panel id="all">
<are-packages-shown value="true" />
<is-autoscroll-to-source value="true" />
</todo-panel>
</component>
<component name="ToolWindowManager">
<frame x="1922" y="25" width="1916" height="1030" extended-state="6" />
<editor active="true" />
<layout>
<window_info anchor="bottom" id="TODO" order="6" sideWeight="0.49946582" weight="0.32903227" />
<window_info anchor="bottom" id="Android Profiler" sideWeight="0.49893162" weight="0.6827957" />
<window_info anchor="bottom" id="Messages" sideWeight="0.49839744" weight="0.32903227" />
<window_info anchor="right" id="Palette&#9;" />
<window_info id="Image Layers" />
<window_info id="Build Variants" sideWeight="0.5016026" side_tool="true" weight="0.24946581" />
<window_info anchor="right" id="Capture Analysis" />
<window_info anchor="bottom" id="Event Log" sideWeight="0.5037393" side_tool="true" visible="true" weight="0.32903227" />
<window_info anchor="right" id="Preview" weight="0.32959402" />
<window_info anchor="bottom" id="Version Control" />
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.48985043" weight="0.32903227" />
<window_info anchor="bottom" id="Terminal" weight="0.32903227" />
<window_info anchor="bottom" id="Logcat" sideWeight="0.49626067" visible="true" weight="0.32903227" />
<window_info id="Captures" order="2" weight="0.25" />
<window_info id="Capture Tool" />
<window_info id="Designer" />
<window_info active="true" content_ui="combo" id="Project" order="0" sideWeight="0.49839744" visible="true" weight="0.24946581" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info id="Structure" order="1" sideWeight="0.5016026" side_tool="true" weight="0.24946581" />
<window_info anchor="right" id="Theme Preview" />
<window_info id="Favorites" sideWeight="0.5016026" side_tool="true" weight="0.24946581" />
<window_info anchor="bottom" id="Debug" order="3" sideWeight="0.49091882" weight="0.4" />
<window_info anchor="right" id="Device File Explorer" side_tool="true" weight="0.32959402" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
</layout>
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<breakpoint enabled="true" type="OCSymbolicBreakpointType">
<properties>
<option name="moduleName" value="libart.so" />
<option name="symbolPattern" value="art_sigsegv_fault" />
</properties>
<option name="timeStamp" value="3" />
</breakpoint>
</breakpoints>
<option name="time" value="4" />
</breakpoint-manager>
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/llarp/android/ifaddrs.c">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-11">
<caret line="451" column="23" selection-start-line="451" selection-start-column="23" selection-end-line="451" selection-end-column="23" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/android/src/network/loki/lokinet/PermsAskerActivity.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1695">
<caret line="124" column="17" selection-start-line="124" selection-start-column="17" selection-end-line="124" selection-end-column="17" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/android/src/network/loki/lokinet/PermsExplanationActivity.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="255">
<caret line="24" column="5" selection-start-line="24" selection-start-column="5" selection-end-line="24" selection-end-column="5" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/android/AndroidManifest.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="409">
<caret line="43" column="31" selection-start-line="43" selection-start-column="31" selection-end-line="43" selection-end-column="31" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/android/src/network/loki/lokinet/ForegroundService.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="75">
<caret line="5" column="25" selection-start-line="5" selection-start-column="25" selection-end-line="5" selection-end-column="25" />
<folding>
<element signature="e#188#189#0" expanded="true" />
<element signature="e#236#237#0" expanded="true" />
<element signature="e#476#477#0" expanded="true" />
<element signature="e#515#516#0" expanded="true" />
<element signature="e#379#380#0" expanded="true" />
<element signature="e#419#420#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/android/res/menu/options_main.xml">
<provider editor-type-id="android-designer2">
<state />
</provider>
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="225">
<caret line="15" column="7" selection-start-line="15" selection-start-column="7" selection-end-line="15" selection-end-column="7" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/android/res/values/strings.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="225">
<caret line="15" selection-start-line="15" selection-end-line="15" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/android/src/network/loki/lokinet/LokiNetActivity.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1249">
<caret line="128" column="24" selection-start-line="128" selection-start-column="24" selection-end-line="128" selection-end-column="24" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
<component name="masterDetails">
<states>
<state key="ArtifactsStructureConfigurable.UI">
<settings>
<artifact-editor />
<last-edited>loki-network</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
<option value="0.5" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="FacetStructureConfigurable.UI">
<settings>
<last-edited>Android</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="GlobalLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="JdkListConfigurable.UI">
<settings>
<last-edited>1.8</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ModuleStructureConfigurable.UI">
<settings>
<last-edited>loki-network</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
<option value="0.6" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ProjectLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>

@ -1,31 +0,0 @@
{
"configurations": [
{
"name": "Linux",
"browse": {
"path": [
"${workspaceFolder}/llarp",
"${workspaceFolder}/daemon",
"${workspaceFolder}/include",
"${workspaceFolder}/libabyss/src",
"${workspaceFolder}/crypto",
"${workspaceFolder}/vendor/cppbackport-master/lib"
],
"limitSymbolsToIncludedHeaders": true
},
"includePath": [
"${workspaceFolder}/include",
"${workspaceFolder}/llarp",
"${workspaceFolder}/vendor/cppbackport-master/lib",
"${workspaceFolder}/libabyss/include",
"${workspaceFolder}/crypto/include"
],
"defines": [],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}

@ -1,36 +0,0 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [{
"name": "(lldb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/testAll",
"args": ["--gtest_shuffle", "--gtest_filter=TestThreadPool*"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb"
},
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/lokinet",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}]
}
]
}

@ -1,76 +0,0 @@
{
"editor.formatOnSave": true,
"files.associations": {
"array": "cpp",
"limits": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"atomic": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"chrono": "cpp",
"codecvt": "cpp",
"condition_variable": "cpp",
"cstdint": "cpp",
"deque": "cpp",
"list": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"exception": "cpp",
"filesystem": "cpp",
"string_view": "cpp",
"fstream": "cpp",
"functional": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"memory": "cpp",
"mutex": "cpp",
"optional": "cpp",
"ostream": "cpp",
"ratio": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"system_error": "cpp",
"thread": "cpp",
"cinttypes": "cpp",
"type_traits": "cpp",
"tuple": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"utility": "cpp",
"__config": "cpp",
"__nullptr": "cpp",
"algorithm": "cpp",
"io": "cpp",
"strstream": "cpp",
"numeric": "cpp",
"valarray": "cpp",
"*.ipp": "cpp",
"csignal": "cpp",
"future": "cpp",
"map": "cpp",
"vector": "cpp",
"new": "cpp",
"shared_mutex": "cpp",
"complex": "cpp",
"variant": "cpp",
"any": "cpp",
"tuntap.h": "c",
"hashtable": "cpp",
"__mutex_base": "cpp",
"iterator": "cpp"
}
}

16
.vscode/tasks.json vendored

@ -1,16 +0,0 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "make -j8 JSONRPC=ON test",
"group": "build",
"problemMatcher": [
"$gcc"
]
}
]
}

@ -45,8 +45,12 @@ add_compile_options(-Wno-cast-function-type)
set(FS_LIB stdc++fs) set(FS_LIB stdc++fs)
endif(WIN32) endif(WIN32)
if(DEBIAN) if(DEBIAN)
add_definitions(-DDEBIAN) add_definitions(-DDEBIAN)
else()
set(CRYPTO_FLAGS -march=native)
endif() endif()
set(CMAKE_THREAD_PREFER_PTHREAD TRUE) set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
@ -112,18 +116,6 @@ if(CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]")
add_compile_options( ${DEBUG_FLAGS} ) add_compile_options( ${DEBUG_FLAGS} )
endif() endif()
if(NOT DEBIAN)
if(NOT ANDROID)
if (NOT USE_AVX2)
set(CRYPTO_FLAGS -march=core2 -mtune=native)
set(CMAKE_ASM_FLAGS "-march=core2")
else()
set(CRYPTO_FLAGS -march=haswell -mtune=native)
set(CMAKE_ASM_FLAGS "-march=haswell -mtune=native ${CMAKE_ASM_FLAGS} $ENV{ASFLAGS}")
endif()
endif()
endif()
if(RPI) if(RPI)
add_definitions(-DRPI) add_definitions(-DRPI)
set(WITH_STATIC ON) set(WITH_STATIC ON)

@ -52,12 +52,13 @@ RPI ?= OFF
STATIC_LINK ?= OFF STATIC_LINK ?= OFF
NETNS ?= OFF NETNS ?= OFF
CLANG ?= OFF CLANG ?= OFF
CROSS ?= OFF
CMAKE_GEN ?= Unix Makefiles CMAKE_GEN ?= Unix Makefiles
BUILD_ROOT = $(REPO)/build BUILD_ROOT = $(REPO)/build
CONFIG_CMD = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "cmake -G'$(CMAKE_GEN)' -DUSING_CLANG=$(CLANG) -DSTATIC_LINK=$(STATIC_LINK) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DUSE_LIBABYSS=$(JSONRPC) -DRPI=$(RPI) '$(REPO)'") CONFIG_CMD = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DUSING_CLANG=$(CLANG) -DSTATIC_LINK=$(STATIC_LINK) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DUSE_LIBABYSS=$(JSONRPC) -DRPI=$(RPI) '$(REPO)'")
SCAN_BUILD ?= scan-build SCAN_BUILD ?= scan-build
ANALYZE_CONFIG_CMD = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "$(SCAN_BUILD) cmake -DUSE_LIBABYSS=$(JSONRPC) '$(REPO)'") ANALYZE_CONFIG_CMD = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "$(SCAN_BUILD) cmake -DUSE_LIBABYSS=$(JSONRPC) '$(REPO)'")

@ -0,0 +1,10 @@
FROM ubuntu:latest
RUN apt update && \
apt install -y build-essential cmake git libcap-dev wget rapidjson-dev
WORKDIR /src/
COPY . /src/
RUN make -j 8 JSONRPC=ON

@ -17,19 +17,19 @@ namespace llarp
const byte_t* const byte_t*
pq_keypair_to_secret(const byte_t* keypair); pq_keypair_to_secret(const byte_t* keypair);
typedef AlignedBuffer< SHAREDKEYSIZE > SharedSecret; using SharedSecret = AlignedBuffer< SHAREDKEYSIZE >;
typedef AlignedBuffer< 32 > KeyExchangeNonce; using KeyExchangeNonce = AlignedBuffer< 32 >;
typedef AlignedBuffer< PUBKEYSIZE > PubKey; using PubKey = AlignedBuffer< PUBKEYSIZE >;
typedef AlignedBuffer< SECKEYSIZE > SecretKey; using SecretKey = AlignedBuffer< SECKEYSIZE >;
typedef AlignedBuffer< SHORTHASHSIZE > ShortHash; using ShortHash = AlignedBuffer< SHORTHASHSIZE >;
typedef AlignedBuffer< SIGSIZE > Signature; using Signature = AlignedBuffer< SIGSIZE >;
typedef AlignedBuffer< TUNNONCESIZE > TunnelNonce; using TunnelNonce = AlignedBuffer< TUNNONCESIZE >;
typedef AlignedBuffer< NONCESIZE > SymmNonce; using SymmNonce = AlignedBuffer< NONCESIZE >;
typedef AlignedBuffer< 32 > SymmKey; using SymmKey = AlignedBuffer< 32 >;
typedef AlignedBuffer< PQ_CIPHERTEXTSIZE + 1 > PQCipherBlock; using PQCipherBlock = AlignedBuffer< PQ_CIPHERTEXTSIZE + 1 >;
typedef AlignedBuffer< PQ_PUBKEYSIZE > PQPubKey; using PQPubKey = AlignedBuffer< PQ_PUBKEYSIZE >;
typedef AlignedBuffer< PQ_KEYPAIRSIZE > PQKeyPair; using PQKeyPair = AlignedBuffer< PQ_KEYPAIRSIZE >;
} // namespace llarp } // namespace llarp

@ -14,7 +14,7 @@ namespace llarp
template < typename Val_t > template < typename Val_t >
struct Bucket struct Bucket
{ {
typedef std::map< Key_t, Val_t, XorMetric > BucketStorage_t; using BucketStorage_t = std::map< Key_t, Val_t, XorMetric >;
Bucket(const Key_t& us) : nodes(XorMetric(us)){}; Bucket(const Key_t& us) : nodes(XorMetric(us)){};

@ -74,7 +74,7 @@ namespace llarp
Validate(const V& value) const = 0; Validate(const V& value) const = 0;
void void
OnFound(const Key_t& askedPeer, const V& value) OnFound(const Key_t askedPeer, const V& value)
{ {
peersAsked.insert(askedPeer); peersAsked.insert(askedPeer);
if(Validate(value)) if(Validate(value))
@ -98,18 +98,26 @@ namespace llarp
Key_t peer; Key_t peer;
if(next) if(next)
{ {
peer = *next.get(); // explicit next peer provided
peer = next->data();
} }
else else if(!GetNextPeer(peer, peersAsked))
{ {
if(!GetNextPeer(peer, peersAsked)) // no more peers
{ llarp::LogInfo("no more peers for request asking for", target);
// no more peers return false;
SendReply();
return false;
}
} }
const Key_t targetKey = target.data();
if((prevPeer ^ targetKey) < (peer ^ targetKey))
{
// next peer is not closer
llarp::LogInfo("next peer ", peer, " is not closer to ", target,
" than ", prevPeer);
return false;
}
else
peersAsked.insert(peer);
DoNextRequest(peer); DoNextRequest(peer);
return true; return true;
} }
@ -118,11 +126,11 @@ namespace llarp
SendReply() = 0; SendReply() = 0;
}; };
typedef std::function< void(const std::vector< service::IntroSet >&) > using IntroSetLookupHandler =
IntroSetLookupHandler; std::function< void(const std::vector< service::IntroSet >&) >;
typedef std::function< void(const std::vector< RouterContact >&) > using RouterLookupHandler =
RouterLookupHandler; std::function< void(const std::vector< RouterContact >&) >;
struct Context struct Context
{ {
@ -297,6 +305,7 @@ namespace llarp
{ {
(void)whoasked; (void)whoasked;
tx.emplace(askpeer, std::unique_ptr< TX< K, V > >(t)); tx.emplace(askpeer, std::unique_ptr< TX< K, V > >(t));
auto count = waiting.count(k);
waiting.insert(std::make_pair(k, askpeer)); waiting.insert(std::make_pair(k, askpeer));
auto itr = timeouts.find(k); auto itr = timeouts.find(k);
@ -305,7 +314,8 @@ namespace llarp
timeouts.insert( timeouts.insert(
std::make_pair(k, time_now_ms() + requestTimeoutMS)); std::make_pair(k, time_now_ms() + requestTimeoutMS));
} }
t->Start(askpeer); if(count == 0)
t->Start(askpeer);
} }
/// mark tx as not fond /// mark tx as not fond
@ -316,12 +326,11 @@ namespace llarp
auto txitr = tx.find(from); auto txitr = tx.find(from);
if(txitr == tx.end()) if(txitr == tx.end())
return; return;
if(next)
{ // ask for next peer
// ask for next peer if(txitr->second->AskNextPeer(from.node, next))
if(txitr->second->AskNextPeer(from.node, next)) sendReply = false;
sendReply = false;
}
llarp::LogWarn("Target key ", txitr->second->target); llarp::LogWarn("Target key ", txitr->second->target);
Inform(from, txitr->second->target, {}, sendReply, sendReply); Inform(from, txitr->second->target, {}, sendReply, sendReply);
} }

@ -9,8 +9,8 @@
#include "dnsd.hpp" #include "dnsd.hpp"
typedef bool (*map_address_hook_func)(const llarp::service::Address &addr, using map_address_hook_func =
uint32_t ip); std::function< bool(const llarp::service::Address &addr, uint32_t ip) >;
/// dotLokiLookup context/config /// dotLokiLookup context/config
struct dotLokiLookup struct dotLokiLookup

@ -14,8 +14,9 @@
struct dnsd_context; struct dnsd_context;
/// sendto hook functor /// sendto hook functor
typedef ssize_t (*sendto_dns_hook_func)(void *sock, const struct sockaddr *from, using sendto_dns_hook_func =
const void *buffer, size_t length); std::function< ssize_t(void *sock, const struct sockaddr *from,
const void *buffer, size_t length) >;
// FIXME: llarp::Addr // FIXME: llarp::Addr
/// DNS server query request /// DNS server query request
@ -89,9 +90,9 @@ writesend_dnss_revresponse(std::string reverse, const struct sockaddr *from,
// //
/// intercept query hook functor /// intercept query hook functor
typedef dnsd_query_hook_response *(*intercept_query_hook)( using intercept_query_hook = std::function< dnsd_query_hook_response *(
std::string name, const struct sockaddr *from, std::string name, const struct sockaddr *from,
struct dnsd_question_request *request); struct dnsd_question_request *request) >;
// FIXME: llarp::Addr // FIXME: llarp::Addr
/// DNS Server context /// DNS Server context

@ -50,7 +50,7 @@ namespace llarp
template < typename User > template < typename User >
struct AsyncFrameEncrypter struct AsyncFrameEncrypter
{ {
typedef void (*EncryptHandler)(EncryptedFrame*, User*); using EncryptHandler = std::function< void(EncryptedFrame*, User*) >;
static void static void
Encrypt(void* user) Encrypt(void* user)
@ -96,7 +96,7 @@ namespace llarp
template < typename User > template < typename User >
struct AsyncFrameDecrypter struct AsyncFrameDecrypter
{ {
typedef void (*DecryptHandler)(llarp_buffer_t*, User*); using DecryptHandler = std::function< void(llarp_buffer_t*, User*) >;
static void static void
Decrypt(void* user) Decrypt(void* user)

@ -64,7 +64,7 @@ namespace llarp
return out; return out;
out << std::string("/"); out << std::string("/");
#if defined(ANDROID) || defined(RPI) #if defined(ANDROID) || defined(RPI)
snprintf(tmp, sizeof(tmp), "%lu", snprintf(tmp, sizeof(tmp), "%zu",
llarp::bits::count_array_bits(xi.netmask.s6_addr)); llarp::bits::count_array_bits(xi.netmask.s6_addr));
return out << tmp; return out << tmp;
#else #else

@ -119,10 +119,9 @@ namespace llarp
ObtainIPForAddr(const byte_t* addr); ObtainIPForAddr(const byte_t* addr);
protected: protected:
typedef llarp::util::CoDelQueue< using PacketQueue_t = llarp::util::CoDelQueue<
net::IPv4Packet, net::IPv4Packet::GetTime, net::IPv4Packet::PutTime, net::IPv4Packet, net::IPv4Packet::GetTime, net::IPv4Packet::PutTime,
net::IPv4Packet::CompareOrder, net::IPv4Packet::GetNow > net::IPv4Packet::CompareOrder, net::IPv4Packet::GetNow >;
PacketQueue_t;
/// queue for sending packets over the network from us /// queue for sending packets over the network from us
PacketQueue_t m_UserToNetworkPktQueue; PacketQueue_t m_UserToNetworkPktQueue;
/// queue for sending packets to user from network /// queue for sending packets to user from network

@ -133,8 +133,8 @@ namespace llarp
uint32_t tick_id; uint32_t tick_id;
protected: protected:
typedef util::NullLock Lock; using Lock = util::NullLock;
typedef util::NullMutex Mutex; using Mutex = util::NullMutex;
void void
PutSession(ILinkSession* s); PutSession(ILinkSession* s);

@ -14,7 +14,7 @@ namespace llarp
{ {
struct ILinkSession; struct ILinkSession;
typedef std::queue< ILinkMessage* > SendQueue; using SendQueue = std::queue< ILinkMessage* >;
/// parsed link layer message /// parsed link layer message
struct ILinkMessage : public IBEncodeMessage struct ILinkMessage : public IBEncodeMessage

@ -83,7 +83,8 @@ llarp_nodedb_del_rc(struct llarp_nodedb *n, const llarp::RouterID &pk);
/// struct for async rc verification /// struct for async rc verification
struct llarp_async_verify_rc; struct llarp_async_verify_rc;
typedef void (*llarp_async_verify_rc_hook_func)(struct llarp_async_verify_rc *); using llarp_async_verify_rc_hook_func =
std::function< void(struct llarp_async_verify_rc *) >;
/// verify rc request /// verify rc request
struct llarp_async_verify_rc struct llarp_async_verify_rc
@ -118,7 +119,8 @@ llarp_nodedb_async_verify(struct llarp_async_verify_rc *job);
struct llarp_async_load_rc; struct llarp_async_load_rc;
typedef void (*llarp_async_load_rc_hook_func)(struct llarp_async_load_rc *); using llarp_async_load_rc_hook_func =
std::function< void(struct llarp_async_load_rc *) >;
struct llarp_async_load_rc struct llarp_async_load_rc
{ {

@ -280,19 +280,19 @@ namespace llarp
/// A path we made /// A path we made
struct Path : public IHopHandler, public llarp::routing::IMessageHandler struct Path : public IHopHandler, public llarp::routing::IMessageHandler
{ {
typedef std::function< void(Path*) > BuildResultHookFunc; using BuildResultHookFunc = std::function< void(Path*) >;
typedef std::function< bool(Path*, llarp_time_t) > CheckForDeadFunc; using CheckForDeadFunc = std::function< bool(Path*, llarp_time_t) >;
typedef std::function< bool(Path*, const PathID_t&, uint64_t) > using DropHandlerFunc =
DropHandlerFunc; std::function< bool(Path*, const PathID_t&, uint64_t) >;
typedef std::vector< PathHopConfig > HopList; using HopList = std::vector< PathHopConfig >;
typedef std::function< bool(Path*, const service::ProtocolFrame*) > using DataHandlerFunc =
DataHandlerFunc; std::function< bool(Path*, const service::ProtocolFrame*) >;
typedef std::function< bool(Path*) > ExitUpdatedFunc; using ExitUpdatedFunc = std::function< bool(Path*) >;
typedef std::function< bool(Path*) > ExitClosedFunc; using ExitClosedFunc = std::function< bool(Path*) >;
typedef std::function< bool(Path*, llarp_buffer_t) > using ExitTrafficHandlerFunc =
ExitTrafficHandlerFunc; std::function< bool(Path*, llarp_buffer_t) >;
/// (path, backoff) backoff is 0 on success /// (path, backoff) backoff is 0 on success
typedef std::function< bool(Path*, llarp_time_t) > ObtainedExitHandler; using ObtainedExitHandler = std::function< bool(Path*, llarp_time_t) >;
HopList hops; HopList hops;
@ -612,15 +612,15 @@ namespace llarp
void void
RemovePathSet(PathSet* set); RemovePathSet(PathSet* set);
typedef std::multimap< PathID_t, std::shared_ptr< TransitHop > > using TransitHopsMap_t =
TransitHopsMap_t; std::multimap< PathID_t, std::shared_ptr< TransitHop > >;
typedef std::pair< util::Mutex, TransitHopsMap_t > SyncTransitMap_t; using SyncTransitMap_t = std::pair< util::Mutex, TransitHopsMap_t >;
// maps path id -> pathset owner of path // maps path id -> pathset owner of path
typedef std::map< PathID_t, PathSet* > OwnedPathsMap_t; using OwnedPathsMap_t = std::map< PathID_t, PathSet* >;
typedef std::pair< util::Mutex, OwnedPathsMap_t > SyncOwnedPathsMap_t; using SyncOwnedPathsMap_t = std::pair< util::Mutex, OwnedPathsMap_t >;
llarp_threadpool* llarp_threadpool*
Worker(); Worker();

@ -6,7 +6,7 @@
namespace llarp namespace llarp
{ {
typedef AlignedBuffer< PATHIDSIZE > PathID_t; using PathID_t = AlignedBuffer< PATHIDSIZE >;
} }
#endif #endif

@ -60,6 +60,10 @@ namespace llarp
void void
Tick(llarp_time_t now, llarp_router* r); Tick(llarp_time_t now, llarp_router* r);
/// count the number of paths that will exist at this timestamp in future
size_t
NumPathsExistingAt(llarp_time_t futureTime) const;
void void
RemovePath(Path* path); RemovePath(Path* path);
@ -176,7 +180,7 @@ namespace llarp
size_t m_NumPaths; size_t m_NumPaths;
private: private:
typedef std::pair< RouterID, PathID_t > PathInfo_t; using PathInfo_t = std::pair< RouterID, PathID_t >;
struct PathInfoHash struct PathInfoHash
{ {
@ -187,7 +191,7 @@ namespace llarp
} }
}; };
typedef std::unordered_map< PathInfo_t, Path*, PathInfoHash > PathMap_t; using PathMap_t = std::unordered_map< PathInfo_t, Path*, PathInfoHash >;
PathMap_t m_Paths; PathMap_t m_Paths;
}; };

@ -69,8 +69,8 @@ namespace llarp
MarkPathSuccess(path::Path* p); MarkPathSuccess(path::Path* p);
private: private:
typedef llarp::util::Lock lock_t; using lock_t = llarp::util::Lock;
typedef llarp::util::Mutex mtx_t; using mtx_t = llarp::util::Mutex;
mtx_t m_ProfilesMutex; mtx_t m_ProfilesMutex;
std::map< RouterID, RouterProfile > m_Profiles; std::map< RouterID, RouterProfile > m_Profiles;
}; };

@ -5,7 +5,7 @@
namespace llarp namespace llarp
{ {
typedef AlignedBuffer< 32 > RouterID; using RouterID = AlignedBuffer< 32 >;
} }
#endif #endif

@ -6,7 +6,7 @@
namespace llarp namespace llarp
{ {
typedef AlignedBuffer< 32 > RoutingEndpoint_t; using RoutingEndpoint_t = AlignedBuffer< 32 >;
/// Interface for end to end crypto between endpoints /// Interface for end to end crypto between endpoints
struct IRoutingEndpoint struct IRoutingEndpoint
@ -15,4 +15,4 @@ namespace llarp
}; };
} // namespace llarp } // namespace llarp
#endif #endif

@ -41,9 +41,12 @@ namespace llarp
Start(const std::string& remote); Start(const std::string& remote);
/// test if a router is valid /// test if a router is valid
bool
VerifyRouter(const llarp::PubKey& pk);
/// do per second tick
void void
VerifyRouter(llarp::PubKey pkey, Tick(llarp_time_t now);
std::function< void(llarp::PubKey, bool) > handler);
private: private:
CallerImpl* m_Impl; CallerImpl* m_Impl;

@ -9,9 +9,9 @@ namespace llarp
{ {
struct Config struct Config
{ {
typedef std::list< std::pair< std::string, std::string > > using section_values_t =
section_values_t; std::list< std::pair< std::string, std::string > >;
typedef std::pair< std::string, section_values_t > section_t; using section_t = std::pair< std::string, section_values_t >;
std::list< section_t > services; std::list< section_t > services;
@ -20,4 +20,4 @@ namespace llarp
}; };
} // namespace service } // namespace service
} // namespace llarp } // namespace llarp
#endif #endif

@ -137,8 +137,13 @@ namespace llarp
HandleDataMessage(const PathID_t&, ProtocolMessage* msg); HandleDataMessage(const PathID_t&, ProtocolMessage* msg);
virtual bool virtual bool
ProcessDataMessage(__attribute__((unused)) ProtocolMessage* msg) ProcessDataMessage(ProtocolMessage* msg)
{ {
#ifdef TESTNET
llarp::LogInfo("Got message from ", msg->sender.Addr());
#else
(void)msg;
#endif
return true; return true;
} }
@ -188,7 +193,7 @@ namespace llarp
bool bool
CheckPathIsDead(path::Path* p, llarp_time_t latency); CheckPathIsDead(path::Path* p, llarp_time_t latency);
typedef std::queue< PendingBuffer > PendingBufferQueue; using PendingBufferQueue = std::queue< PendingBuffer >;
struct SendContext struct SendContext
{ {
@ -326,7 +331,7 @@ namespace llarp
// passed a sendto context when we have a path established otherwise // passed a sendto context when we have a path established otherwise
// nullptr if the path was not made before the timeout // nullptr if the path was not made before the timeout
typedef std::function< void(Address, OutboundContext*) > PathEnsureHook; using PathEnsureHook = std::function< void(Address, OutboundContext*) >;
/// return false if we have already called this function before for this /// return false if we have already called this function before for this
/// address /// address

@ -9,7 +9,7 @@ namespace llarp
{ {
namespace service namespace service
{ {
typedef llarp::AlignedBuffer< 16 > ConvoTag; using ConvoTag = llarp::AlignedBuffer< 16 >;
struct ProtocolMessage; struct ProtocolMessage;
struct IDataHandler struct IDataHandler

@ -17,7 +17,7 @@ namespace llarp
{ {
constexpr std::size_t MAX_PROTOCOL_MESSAGE_SIZE = 2048 * 2; constexpr std::size_t MAX_PROTOCOL_MESSAGE_SIZE = 2048 * 2;
typedef uint64_t ProtocolType; using ProtocolType = uint64_t;
constexpr ProtocolType eProtocolText = 0UL; constexpr ProtocolType eProtocolText = 0UL;
constexpr ProtocolType eProtocolTraffic = 1UL; constexpr ProtocolType eProtocolTraffic = 1UL;

@ -8,7 +8,7 @@ namespace llarp
{ {
/// hidden service address /// hidden service address
typedef llarp::AlignedBuffer< 16 > VanityNonce; using VanityNonce = llarp::AlignedBuffer< 16 >;
} // namespace service } // namespace service
} // namespace llarp } // namespace llarp
#endif #endif

@ -6,7 +6,7 @@
#include <string> #include <string>
namespace llarp namespace llarp
{ {
typedef std::string_view string_view; using string_view = std::string_view;
static std::string static std::string
string_view_string(const string_view& v) string_view_string(const string_view& v)
{ {
@ -17,7 +17,7 @@ namespace llarp
#include <string> #include <string>
namespace llarp namespace llarp
{ {
typedef std::string string_view; using string_view = std::string;
static std::string static std::string
string_view_string(const string_view& v) string_view_string(const string_view& v)
@ -26,4 +26,4 @@ namespace llarp
}; };
} // namespace llarp } // namespace llarp
#endif #endif
#endif #endif

@ -34,9 +34,9 @@ namespace llarp
} }
}; };
typedef std::mutex mtx_t; using mtx_t = std::mutex;
typedef std::unique_lock< std::mutex > lock_t; using lock_t = std::unique_lock< std::mutex >;
typedef std::condition_variable cond_t; using cond_t = std::condition_variable;
struct Mutex struct Mutex
{ {

@ -5,8 +5,11 @@
#include <llarp/threadpool.h> #include <llarp/threadpool.h>
#include <llarp/time.hpp> #include <llarp/time.hpp>
#include <functional>
/** called with userptr, original timeout, left */ /** called with userptr, original timeout, left */
typedef void (*llarp_timer_handler_func)(void *, uint64_t, uint64_t); using llarp_timer_handler_func =
std::function< void(void *, uint64_t, uint64_t) >;
struct llarp_timeout_job struct llarp_timeout_job
{ {

@ -3,7 +3,7 @@
#include <cstdint> #include <cstdint>
using llarp_proto_version_t = std::uint8_t; using llarp_proto_version_t = std::uint8_t;
using llarp_time_t = std::uint64_t; using llarp_time_t = std::uint64_t;
using llarp_seconds_t = std::uint64_t; using llarp_seconds_t = std::uint64_t;
#endif #endif

File diff suppressed because it is too large Load Diff

@ -14,10 +14,10 @@ namespace abyss
{ {
namespace http namespace http
{ {
typedef std::string RPC_Method_t; using RPC_Method_t = std::string;
typedef json::Value RPC_Params; using RPC_Params = json::Value;
typedef json::Document RPC_Response; using RPC_Response = json::Document;
typedef std::unordered_multimap< std::string, std::string > Headers_t; using Headers_t = std::unordered_multimap< std::string, std::string >;
struct ConnImpl; struct ConnImpl;
/// jsonrpc response handler for client /// jsonrpc response handler for client
@ -30,7 +30,7 @@ namespace abyss
/// return true on successful handling /// return true on successful handling
/// return false on errors while handling /// return false on errors while handling
virtual bool virtual bool
HandleResponse(const RPC_Response& response) = 0; HandleResponse(RPC_Response response) = 0;
/// populate http request headers /// populate http request headers
virtual void virtual void
@ -55,7 +55,7 @@ namespace abyss
/// jsonrpc client /// jsonrpc client
struct JSONRPC struct JSONRPC
{ {
typedef std::function< IRPCClientHandler*(ConnImpl*) > HandlerFactory; using HandlerFactory = std::function< IRPCClientHandler*(ConnImpl*) >;
JSONRPC(); JSONRPC();
~JSONRPC(); ~JSONRPC();
@ -115,4 +115,4 @@ namespace abyss
} // namespace http } // namespace http
} // namespace abyss } // namespace abyss
#endif #endif

@ -11,7 +11,7 @@ namespace abyss
{ {
struct RequestHeader struct RequestHeader
{ {
typedef std::unordered_multimap< std::string, std::string > Headers_t; using Headers_t = std::unordered_multimap< std::string, std::string >;
Headers_t Headers; Headers_t Headers;
std::string Method; std::string Method;
std::string Path; std::string Path;
@ -33,4 +33,4 @@ namespace abyss
} // namespace http } // namespace http
} // namespace abyss } // namespace abyss
#endif #endif

@ -10,7 +10,7 @@ namespace abyss
{ {
namespace json namespace json
{ {
typedef std::unordered_map< std::string, std::any > Object; using Object = std::unordered_map< std::string, std::any >;
} }
} // namespace abyss } // namespace abyss
#else #else
@ -19,17 +19,17 @@ namespace abyss
{ {
namespace json namespace json
{ {
typedef rapidjson::Document Document; using Document = rapidjson::Document;
typedef rapidjson::Value Value; using Value = rapidjson::Value;
} // namespace json } // namespace json
} // namespace abyss } // namespace abyss
#endif #endif
namespace abyss namespace abyss
{ {
#if __cplusplus >= 201703L #if __cplusplus >= 201703L
typedef std::string_view string_view; using string_view = std::string_view;
#else #else
typedef std::string string_view; using string_view = std::string;
#endif #endif
namespace json namespace json
{ {

@ -19,9 +19,9 @@ namespace abyss
struct IRPCHandler struct IRPCHandler
{ {
typedef std::string Method_t; using Method_t = std::string;
typedef json::Value Params; using Params = json::Value;
typedef json::Document Response; using Response = json::Document;
IRPCHandler(ConnImpl* impl); IRPCHandler(ConnImpl* impl);

@ -29,7 +29,7 @@ struct DemoCall : public abyss::http::IRPCClientHandler
} }
bool bool
HandleResponse(const abyss::http::RPC_Response& resp) override HandleResponse(abyss::http::RPC_Response resp) override
{ {
std::string body; std::string body;
abyss::json::ToString(resp, body); abyss::json::ToString(resp, body);

@ -125,7 +125,7 @@ namespace abyss
case json::IParser::eNeedData: case json::IParser::eNeedData:
return true; return true;
case json::IParser::eDone: case json::IParser::eDone:
handler->HandleResponse(m_Response); handler->HandleResponse(std::move(m_Response));
Close(); Close();
return true; return true;
case json::IParser::eParseError: case json::IParser::eParseError:

@ -36,6 +36,7 @@ namespace llarp
services = find_section(top, "services", section_t{}); services = find_section(top, "services", section_t{});
system = find_section(top, "system", section_t{}); system = find_section(top, "system", section_t{});
api = find_section(top, "api", section_t{}); api = find_section(top, "api", section_t{});
lokid = find_section(top, "lokid", section_t{});
return true; return true;
} }
return false; return false;
@ -135,11 +136,7 @@ llarp_generic_ensure_config(std::ofstream &f, std::string basepath)
f << "# authkey=insertpubkey1here" << std::endl; f << "# authkey=insertpubkey1here" << std::endl;
f << "# authkey=insertpubkey2here" << std::endl; f << "# authkey=insertpubkey2here" << std::endl;
f << "# authkey=insertpubkey3here" << std::endl; f << "# authkey=insertpubkey3here" << std::endl;
#ifdef _WIN32
f << "bind=127.0.0.1:1190" << std::endl; f << "bind=127.0.0.1:1190" << std::endl;
#else
f << "bind=unix:" << basepath << "api.socket" << std::endl;
#endif
f << std::endl << std::endl; f << std::endl << std::endl;
f << "# system settings for priviledges and such" << std::endl; f << "# system settings for priviledges and such" << std::endl;
@ -165,6 +162,7 @@ llarp_generic_ensure_config(std::ofstream &f, std::string basepath)
// Make auto-config smarter // Make auto-config smarter
// will this break reproducibility rules? // will this break reproducibility rules?
// (probably)
#ifdef __linux__ #ifdef __linux__
f << "bind=127.3.2.1:53" << std::endl; f << "bind=127.3.2.1:53" << std::endl;
#else #else
@ -187,6 +185,11 @@ llarp_generic_ensure_config(std::ofstream &f, std::string basepath)
void void
llarp_ensure_router_config(std::ofstream &f, std::string basepath) llarp_ensure_router_config(std::ofstream &f, std::string basepath)
{ {
f << "# lokid settings (disabled by default)" << std::endl;
f << "[lokid]" << std::endl;
f << "enabled=false" << std::endl;
f << "jsonrpc=127.0.0.1:22023" << std::endl;
f << std::endl;
f << "# network settings " << std::endl; f << "# network settings " << std::endl;
f << "[network]" << std::endl; f << "[network]" << std::endl;
f << "profiles=" << basepath << "profiles.dat" << std::endl; f << "profiles=" << basepath << "profiles.dat" << std::endl;

@ -9,7 +9,7 @@ namespace llarp
{ {
struct Config struct Config
{ {
typedef std::list< std::pair< std::string, std::string > > section_t; using section_t = std::list< std::pair< std::string, std::string > >;
section_t router; section_t router;
section_t network; section_t network;
@ -20,6 +20,7 @@ namespace llarp
section_t services; section_t services;
section_t system; section_t system;
section_t api; section_t api;
section_t lokid;
bool bool
Load(const char *fname); Load(const char *fname);

@ -47,32 +47,32 @@ namespace llarp
} }
bool bool
Validate(const RouterID &) const Validate(const RouterID &) const override
{ {
// TODO: check with lokid // TODO: check with lokid
return true; return true;
} }
void void
Start(const TXOwner &peer) Start(const TXOwner &peer) override
{ {
parent->DHTSendTo(peer.node, parent->DHTSendTo(peer.node,
new FindRouterMessage(parent->OurKey(), peer.txid)); new FindRouterMessage(parent->OurKey(), peer.txid));
} }
bool bool
GetNextPeer(Key_t &, const std::set< Key_t > &) GetNextPeer(Key_t &, const std::set< Key_t > &) override
{ {
return false; return false;
} }
void void
DoNextRequest(const Key_t &) DoNextRequest(const Key_t &) override
{ {
} }
void void
SendReply() SendReply() override
{ {
llarp::LogInfo("got ", valuesFound.size(), " routers from exploration"); llarp::LogInfo("got ", valuesFound.size(), " routers from exploration");
for(const auto &pk : valuesFound) for(const auto &pk : valuesFound)
@ -324,7 +324,7 @@ namespace llarp
} }
bool bool
Validate(const service::IntroSet &value) const Validate(const service::IntroSet &value) const override
{ {
if(!value.Verify(parent->Crypto(), parent->Now())) if(!value.Verify(parent->Crypto(), parent->Now()))
{ {
@ -339,52 +339,33 @@ namespace llarp
return true; return true;
} }
void
DoNextRequest(const Key_t &nextPeer)
{
// iterate to next peer
parent->LookupIntroSetIterative(
target, whoasked.node, whoasked.txid, nextPeer,
std::bind(&ServiceAddressLookup::HandleNextRequestResult, this,
std::placeholders::_1));
}
void
HandleNextRequestResult(const std::vector< service::IntroSet > &results)
{
// merge results
std::set< service::IntroSet > found;
for(const auto &introset : valuesFound)
found.insert(introset);
for(const auto &introset : results)
found.insert(introset);
valuesFound.clear();
for(const auto &introset : found)
valuesFound.push_back(introset);
// send reply
SendReply();
}
bool bool
GetNextPeer(Key_t &next, const std::set< Key_t > &exclude) GetNextPeer(Key_t &next, const std::set< Key_t > &exclude) override
{ {
Key_t k = target.data(); Key_t k = target.data();
return parent->nodes->FindCloseExcluding(k, next, exclude); return parent->nodes->FindCloseExcluding(k, next, exclude);
} }
void void
Start(const TXOwner &peer) Start(const TXOwner &peer) override
{ {
parent->DHTSendTo(peer.node, parent->DHTSendTo(peer.node,
new FindIntroMessage(peer.txid, target, R)); new FindIntroMessage(peer.txid, target, R));
} }
void
DoNextRequest(const Key_t &ask) override
{
if(R)
parent->LookupIntroSetRecursive(target, whoasked.node, whoasked.txid,
ask, R - 1);
else
parent->LookupIntroSetIterative(target, whoasked.node, whoasked.txid,
ask);
}
virtual void virtual void
SendReply() SendReply() override
{ {
if(handleResult) if(handleResult)
handleResult(valuesFound); handleResult(valuesFound);
@ -408,7 +389,7 @@ namespace llarp
} }
void void
SendReply() SendReply() override
{ {
auto path = auto path =
parent->router->paths.GetByUpstream(parent->OurKey(), localPath); parent->router->paths.GetByUpstream(parent->OurKey(), localPath);
@ -461,7 +442,7 @@ namespace llarp
} }
bool bool
Validate(const service::IntroSet &introset) const Validate(const service::IntroSet &introset) const override
{ {
if(I.A != introset.A) if(I.A != introset.A)
{ {
@ -473,7 +454,7 @@ namespace llarp
} }
void void
Start(const TXOwner &peer) Start(const TXOwner &peer) override
{ {
std::vector< Key_t > exclude; std::vector< Key_t > exclude;
for(const auto &router : dontTell) for(const auto &router : dontTell)
@ -483,18 +464,18 @@ namespace llarp
} }
bool bool
GetNextPeer(Key_t &, const std::set< Key_t > &) GetNextPeer(Key_t &, const std::set< Key_t > &) override
{ {
return false; return false;
} }
void void
DoNextRequest(const Key_t &) DoNextRequest(const Key_t &) override
{ {
} }
void void
SendReply() SendReply() override
{ {
// don't need this // don't need this
} }
@ -550,7 +531,7 @@ namespace llarp
} }
bool bool
Validate(const service::IntroSet &introset) const Validate(const service::IntroSet &introset) const override
{ {
if(!introset.Verify(parent->Crypto(), parent->Now())) if(!introset.Verify(parent->Crypto(), parent->Now()))
{ {
@ -566,26 +547,25 @@ namespace llarp
} }
void void
Start(const TXOwner &peer) Start(const TXOwner &peer) override
{ {
parent->DHTSendTo(peer.node, parent->DHTSendTo(peer.node,
new FindIntroMessage(target, peer.txid, R)); new FindIntroMessage(target, peer.txid, R));
} }
bool bool
GetNextPeer(__attribute__((unused)) Key_t &nextpeer, GetNextPeer(Key_t &, const std::set< Key_t > &) override
__attribute__((unused)) const std::set< Key_t > &exclude)
{ {
return false; return false;
} }
void void
DoNextRequest(__attribute__((unused)) const Key_t &nextPeer) DoNextRequest(const Key_t &) override
{ {
} }
void void
SendReply() SendReply() override
{ {
std::set< service::IntroSet > found; std::set< service::IntroSet > found;
for(const auto &remoteTag : valuesFound) for(const auto &remoteTag : valuesFound)
@ -636,7 +616,7 @@ namespace llarp
} }
void void
SendReply() SendReply() override
{ {
auto path = auto path =
parent->router->paths.GetByUpstream(parent->OurKey(), localPath); parent->router->paths.GetByUpstream(parent->OurKey(), localPath);
@ -717,7 +697,7 @@ namespace llarp
} }
bool bool
Validate(const RouterContact &rc) const Validate(const RouterContact &rc) const override
{ {
if(!rc.Verify(parent->Crypto())) if(!rc.Verify(parent->Crypto()))
{ {
@ -728,20 +708,18 @@ namespace llarp
} }
bool bool
GetNextPeer(__attribute__((unused)) Key_t &next, GetNextPeer(Key_t &, const std::set< Key_t > &) override
__attribute__((unused)) const std::set< Key_t > &exclude)
{ {
// TODO: implement iterative (?)
return false; return false;
} }
void void
DoNextRequest(__attribute__((unused)) const Key_t &next) DoNextRequest(const Key_t &) override
{ {
} }
void void
Start(const TXOwner &peer) Start(const TXOwner &peer) override
{ {
parent->DHTSendTo( parent->DHTSendTo(
peer.node, peer.node,
@ -749,7 +727,7 @@ namespace llarp
} }
virtual void virtual void
SendReply() SendReply() override
{ {
if(resultHandler) if(resultHandler)
{ {
@ -777,7 +755,7 @@ namespace llarp
} }
void void
SendReply() SendReply() override
{ {
auto path = auto path =
parent->router->paths.GetByUpstream(parent->OurKey(), localPath); parent->router->paths.GetByUpstream(parent->OurKey(), localPath);

@ -242,8 +242,8 @@ extern "C"
// llarp::LogDebug("Advancing to pos ", std::to_string(*pos)); // llarp::LogDebug("Advancing to pos ", std::to_string(*pos));
moveable += (*pos); // advance to position moveable += (*pos); // advance to position
//hexDump(moveable, 12); // hexDump(moveable, 12);
//hexDumpAt(buffer, *pos, 12); // hexDumpAt(buffer, *pos, 12);
if(*moveable == '\xc0') if(*moveable == '\xc0')
{ {
@ -267,10 +267,10 @@ extern "C"
/* /*
uint32_t readAt32 = *pos; uint32_t readAt32 = *pos;
answer->name = getDNSstring(buffer, &readAt32); answer->name = getDNSstring(buffer, &readAt32);
llarp::LogInfo("Parsed string ", answer->name, " read ", std::to_string(readAt32)); llarp::LogInfo("Parsed string ", answer->name, " read ",
moveable += readAt32; (*pos) += readAt32; std::to_string(readAt32)); moveable += readAt32; (*pos) += readAt32;
*/ */
//moveable++; (*pos)++; // moveable++; (*pos)++;
} }
/* /*
hexDump(moveable, 10); hexDump(moveable, 10);
@ -330,12 +330,12 @@ extern "C"
// FIXME: move this out of here, this shouldn't be responsible for decode // FIXME: move this out of here, this shouldn't be responsible for decode
switch(answer->type) switch(answer->type)
{ {
case 2: // NS case 2: // NS
// don't really need to do anything here // don't really need to do anything here
moveable += answer->rdLen; moveable += answer->rdLen;
(*pos) += answer->rdLen; // advance the length (*pos) += answer->rdLen; // advance the length
break; break;
case 5: case 5:
moveable += answer->rdLen; moveable += answer->rdLen;
(*pos) += answer->rdLen; // advance the length (*pos) += answer->rdLen; // advance the length
break; break;
@ -371,10 +371,10 @@ extern "C"
{ {
std::string revname = getDNSstring(buffer, pos); std::string revname = getDNSstring(buffer, pos);
llarp::LogInfo("revDNSname: ", revname); llarp::LogInfo("revDNSname: ", revname);
//answer->rData = new uint8_t[answer->rdLen + 1]; // answer->rData = new uint8_t[answer->rdLen + 1];
answer->rData.resize(answer->rdLen); answer->rData.resize(answer->rdLen);
memcpy(answer->rData.data(), revname.c_str(), answer->rdLen); memcpy(answer->rData.data(), revname.c_str(), answer->rdLen);
//answer->rData = (uint8_t *)strdup(revname.c_str()); // safer? nope // answer->rData = (uint8_t *)strdup(revname.c_str()); // safer? nope
moveable += answer->rdLen; moveable += answer->rdLen;
//(*pos) += answer->rdLen; // advance the length //(*pos) += answer->rdLen; // advance the length
} }

@ -229,9 +229,10 @@ ReverseHandlerIter(struct llarp::service::Context::endpoint_iter *endpointCfg)
+ tokensCheck[2] + "." + tokensCheck[3]; + tokensCheck[2] + "." + tokensCheck[3];
llarp::LogDebug(searchIp, " vs ", checkIp); llarp::LogDebug(searchIp, " vs ", checkIp);
llarp::IPRange range = llarp::iprange_ipv4( llarp::IPRange range =
std::stoi(tokensCheck[0]), std::stoi(tokensCheck[1]), std::stoi(tokensCheck[2]), llarp::iprange_ipv4(std::stoi(tokensCheck[0]), std::stoi(tokensCheck[1]),
std::stoi(tokensCheck[3]), tunEndpoint->tunif.netmask); // create range std::stoi(tokensCheck[2]), std::stoi(tokensCheck[3]),
tunEndpoint->tunif.netmask); // create range
// hack atm to work around limitations in ipaddr_ipv4_bits and llarp::IPRange // hack atm to work around limitations in ipaddr_ipv4_bits and llarp::IPRange
llarp::huint32_t searchIPv4_fixed = llarp::ipaddr_ipv4_bits( llarp::huint32_t searchIPv4_fixed = llarp::ipaddr_ipv4_bits(
std::stoi(tokensSearch[searchTokens - 6]), std::stoi(tokensSearch[searchTokens - 6]),

@ -224,13 +224,14 @@ generic_handle_dnsc_recvfrom(dnsc_answer_request *request,
for(uint32_t i = 0; i < hdr->qdCount; i++) for(uint32_t i = 0; i < hdr->qdCount; i++)
{ {
question = decode_question(castBufc, &pos); question = decode_question(castBufc, &pos);
//llarp::LogDebug("Read a question, now at ", std::to_string(pos)); // llarp::LogDebug("Read a question, now at ", std::to_string(pos));
// 1 dot: 1 byte for length + length // 1 dot: 1 byte for length + length
// 4 bytes for class/type // 4 bytes for class/type
// castBuf += question->name.length() + 1 + 4; // castBuf += question->name.length() + 1 + 4;
// castBuf += 2; // skip answer label // castBuf += 2; // skip answer label
} }
llarp::LogDebug("Question ", std::to_string(question->type), " ", question->name); llarp::LogDebug("Question ", std::to_string(question->type), " ",
question->name);
// FIXME: only handling one atm // FIXME: only handling one atm
std::vector< dns_msg_answer * > answers; std::vector< dns_msg_answer * > answers;
@ -296,15 +297,15 @@ generic_handle_dnsc_recvfrom(dnsc_answer_request *request,
// pos = 0; // reset pos // pos = 0; // reset pos
answer = decode_answer(castBufc, &pos); answer = decode_answer(castBufc, &pos);
// answers.push_back(answer); // answers.push_back(answer);
llarp::LogDebug("Read an authority for ", llarp::LogDebug("Read an authority for ", request->question.name, " at ",
request->question.name, " at ", std::to_string(pos)); std::to_string(pos));
// castBuf += answer->name.length() + 4 + 4 + 4 + answer->rdLen; // castBuf += answer->name.length() + 4 + 4 + 4 + answer->rdLen;
if((ssize_t)pos > sz) if((ssize_t)pos > sz)
{ {
llarp::LogWarn("Would read past end of dns packet. for ", llarp::LogWarn("Would read past end of dns packet. for ",
request->question.name); request->question.name);
break; break;
} }
} }
/* /*
@ -393,14 +394,14 @@ generic_handle_dnsc_recvfrom(dnsc_answer_request *request,
int ip = 0; int ip = 0;
// if no answer, just bail now // if no answer, just bail now
if (!answer) if(!answer)
{ {
request->found = false; request->found = false;
request->resolved(request); request->resolved(request);
return; return;
} }
/* search for and print IPv4 addresses */ /* search for and print IPv4 addresses */
// if(dnsQuery->reqType == 0x01) // if(dnsQuery->reqType == 0x01)
/* /*
@ -603,7 +604,7 @@ llarp_handle_dnsc_recvfrom(struct llarp_udp_io *const udp,
llarp::LogDebug("Header got client responses for id: ", hdr->id); llarp::LogDebug("Header got client responses for id: ", hdr->id);
// if we sent this out, then there's an id // if we sent this out, then there's an id
struct dns_tracker *tracker = (struct dns_tracker *)udp->user; struct dns_tracker *tracker = (struct dns_tracker *)udp->user;
struct dnsc_answer_request *request = tracker->client_request[hdr->id].get(); struct dnsc_answer_request *request = tracker->client_request[hdr->id].get();
// sometimes we'll get double responses // sometimes we'll get double responses
@ -694,7 +695,7 @@ void
llarp_host_resolved(dnsc_answer_request *const request) llarp_host_resolved(dnsc_answer_request *const request)
{ {
dns_tracker *tracker = (dns_tracker *)request->context->tracker; dns_tracker *tracker = (dns_tracker *)request->context->tracker;
auto val = std::find_if( auto val = std::find_if(
tracker->client_request.begin(), tracker->client_request.end(), tracker->client_request.begin(), tracker->client_request.end(),
[request]( [request](
std::pair< const uint32_t, std::unique_ptr< dnsc_answer_request > > std::pair< const uint32_t, std::unique_ptr< dnsc_answer_request > >
@ -735,7 +736,7 @@ llarp_dnsc_init(struct dnsc_context *const dnsc,
llarp::LogInfo("DNSc adding relay ", dnsc_sockaddr); llarp::LogInfo("DNSc adding relay ", dnsc_sockaddr);
dnsc->resolvers.push_back(dnsc_sockaddr); dnsc->resolvers.push_back(dnsc_sockaddr);
dnsc->tracker = &dns_udp_tracker; dnsc->tracker = &dns_udp_tracker;
dnsc->logic = logic; dnsc->logic = logic;
return true; return true;
} }

@ -83,13 +83,13 @@ namespace llarp
}; };
}; };
typedef llarp::util::CoDelQueue< WriteBuffer, WriteBuffer::GetTime, using LossyWriteQueue_t =
WriteBuffer::PutTime, WriteBuffer::Compare, llarp::util::CoDelQueue< WriteBuffer, WriteBuffer::GetTime,
llarp::util::NullMutex, WriteBuffer::PutTime, WriteBuffer::Compare,
llarp::util::NullLock, 5, 100, 128 > llarp::util::NullMutex, llarp::util::NullLock,
LossyWriteQueue_t; 5, 100, 128 >;
typedef std::deque< WriteBuffer > LosslessWriteQueue_t; using LosslessWriteQueue_t = std::deque< WriteBuffer >;
// on windows, tcp/udp event loops are socket fds // on windows, tcp/udp event loops are socket fds
// and TUN device is a plain old fd // and TUN device is a plain old fd
@ -319,13 +319,13 @@ namespace llarp
}; };
}; };
typedef llarp::util::CoDelQueue< using LossyWriteQueue_t =
WriteBuffer, WriteBuffer::GetTime, WriteBuffer::PutTime, llarp::util::CoDelQueue< WriteBuffer, WriteBuffer::GetTime,
WriteBuffer::Compare, WriteBuffer::GetNow, llarp::util::NullMutex, WriteBuffer::PutTime, WriteBuffer::Compare,
llarp::util::NullLock, 5, 100, 1024 > WriteBuffer::GetNow, llarp::util::NullMutex,
LossyWriteQueue_t; llarp::util::NullLock, 5, 100, 1024 >;
typedef std::deque< WriteBuffer > LosslessWriteQueue_t; using LosslessWriteQueue_t = std::deque< WriteBuffer >;
int fd; int fd;
int flags = 0; int flags = 0;

@ -215,7 +215,7 @@ namespace llarp
llarp_tun_io* t; llarp_tun_io* t;
device* tunif; device* tunif;
tun(llarp_tun_io* tio, llarp_ev_loop* l) tun(llarp_tun_io* tio, llarp_ev_loop* l)
: ev_io(-1, new LossyWriteQueue_t("kqueue_tun_write", l)) : ev_io(-1, new LossyWriteQueue_t("kqueue_tun_write", l, l))
, t(tio) , t(tio)
, tunif(tuntap_init()){}; , tunif(tuntap_init()){};

@ -22,8 +22,12 @@ namespace llarp
bool bool
BaseSession::ShouldBuildMore(llarp_time_t now) const BaseSession::ShouldBuildMore(llarp_time_t now) const
{ {
return AvailablePaths(llarp::path::ePathRoleExit) == 0 const size_t expect = (1 + (m_NumPaths / 2));
|| path::Builder::ShouldBuildMore(now); if(NumPathsExistingAt(now + (10 * 1000)) < expect)
return true;
if(AvailablePaths(llarp::path::ePathRoleExit) < expect)
return true;
return false;
} }
bool bool

@ -22,8 +22,8 @@ namespace llarp
{ {
namespace util namespace util
{ {
typedef std::function< bool(const fs::path &) > PathVisitor; using PathVisitor = std::function< bool(const fs::path &) >;
typedef std::function< void(const fs::path &, PathVisitor) > PathIter; using PathIter = std::function< void(const fs::path &, PathVisitor) >;
static PathIter IterDir = [](const fs::path &path, PathVisitor visit) { static PathIter IterDir = [](const fs::path &path, PathVisitor visit) {
DIR *d = opendir(path.string().c_str()); DIR *d = opendir(path.string().c_str());

@ -300,7 +300,9 @@ namespace llarp
return false; return false;
huint32_t ip = GetIPForIdent(pk); huint32_t ip = GetIPForIdent(pk);
m_ActiveExits.insert(std::make_pair( m_ActiveExits.insert(std::make_pair(
pk, new llarp::exit::Endpoint(pk, path, !wantInternet, ip, this))); pk,
std::unique_ptr< llarp::exit::Endpoint >(
new llarp::exit::Endpoint(pk, path, !wantInternet, ip, this))));
m_Paths[path] = pk; m_Paths[path] = pk;
return HasLocalMappedAddrFor(pk); return HasLocalMappedAddrFor(pk);
} }

@ -335,7 +335,7 @@ namespace llarp
TunEndpoint::Tick(llarp_time_t now) TunEndpoint::Tick(llarp_time_t now)
{ {
// call tun code in endpoint logic in case of network isolation // call tun code in endpoint logic in case of network isolation
llarp_logic_queue_job(EndpointLogic(), {this, handleTickTun}); //llarp_logic_queue_job(EndpointLogic(), {this, handleTickTun});
FlushSend(); FlushSend();
Endpoint::Tick(now); Endpoint::Tick(now);
} }

@ -48,9 +48,9 @@ namespace ini
{ {
} }
typedef std::list< std::pair< std::string, std::string > > value_map_t; using value_map_t = std::list< std::pair< std::string, std::string > >;
typedef std::map< std::string, Level > section_map_t; using section_map_t = std::map< std::string, Level >;
typedef std::list< section_map_t::const_iterator > sections_t; using sections_t = std::list< section_map_t::const_iterator >;
value_map_t values; value_map_t values;
section_map_t sections; section_map_t sections;
sections_t ordered_sections; sections_t ordered_sections;

@ -869,12 +869,12 @@ namespace llarp
BaseSession::EnterState(State st) BaseSession::EnterState(State st)
{ {
state = st; state = st;
Alive();
if(st == eSessionReady) if(st == eSessionReady)
{ {
parent->MapAddr(remoteRC.pubkey, this); parent->MapAddr(remoteRC.pubkey, this);
Router()->HandleLinkSessionEstablished(remoteRC); Router()->HandleLinkSessionEstablished(remoteRC, parent);
} }
Alive();
} }
bool bool

@ -152,12 +152,12 @@ _llarp_nt_getadaptersaddresses(struct llarp_nt_ifaddrs_t** ifap)
fprintf(stderr, "IP_ADAPTER_ADDRESSES buffer length %lu bytes.\n", dwSize); fprintf(stderr, "IP_ADAPTER_ADDRESSES buffer length %lu bytes.\n", dwSize);
#endif #endif
pAdapterAddresses = (IP_ADAPTER_ADDRESSES*)_llarp_nt_heap_alloc(dwSize); pAdapterAddresses = (IP_ADAPTER_ADDRESSES*)_llarp_nt_heap_alloc(dwSize);
dwRet = GetAdaptersAddresses( dwRet = GetAdaptersAddresses(AF_UNSPEC,
AF_UNSPEC, GAA_FLAG_INCLUDE_PREFIX | GAA_FLAG_SKIP_ANYCAST
GAA_FLAG_INCLUDE_PREFIX | GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_DNS_SERVER
| GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_SKIP_FRIENDLY_NAME | GAA_FLAG_SKIP_FRIENDLY_NAME
| GAA_FLAG_SKIP_MULTICAST, | GAA_FLAG_SKIP_MULTICAST,
nullptr, pAdapterAddresses, &dwSize); nullptr, pAdapterAddresses, &dwSize);
if(ERROR_BUFFER_OVERFLOW == dwRet) if(ERROR_BUFFER_OVERFLOW == dwRet)
{ {
_llarp_nt_heap_free(pAdapterAddresses); _llarp_nt_heap_free(pAdapterAddresses);
@ -378,7 +378,7 @@ _llarp_nt_getadaptersaddresses(struct llarp_nt_ifaddrs_t** ifap)
/* default IPv6 route */ /* default IPv6 route */
if(AF_INET6 == lpSockaddr->sa_family && 0 == prefix->PrefixLength if(AF_INET6 == lpSockaddr->sa_family && 0 == prefix->PrefixLength
&& IN6_IS_ADDR_UNSPECIFIED( && IN6_IS_ADDR_UNSPECIFIED(
&((struct sockaddr_in6*)(lpSockaddr))->sin6_addr)) &((struct sockaddr_in6*)(lpSockaddr))->sin6_addr))
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, fprintf(stderr,
@ -447,10 +447,10 @@ _llarp_nt_getadaptersaddresses(struct llarp_nt_ifaddrs_t** ifap)
ift->_ifa.ifa_next = (struct llarp_nt_ifaddrs_t*)(ift + 1); ift->_ifa.ifa_next = (struct llarp_nt_ifaddrs_t*)(ift + 1);
ift = (struct _llarp_nt_ifaddrs_t*)(ift->_ifa.ifa_next); ift = (struct _llarp_nt_ifaddrs_t*)(ift->_ifa.ifa_next);
} }
else else
{ {
ift->_ifa.ifa_next = nullptr; ift->_ifa.ifa_next = nullptr;
} }
} }
} }
@ -464,7 +464,7 @@ static unsigned
_llarp_nt_getadaptersaddresses_nametoindex(const char* ifname) _llarp_nt_getadaptersaddresses_nametoindex(const char* ifname)
{ {
ULONG ifIndex; ULONG ifIndex;
DWORD dwSize = 4096, dwRet; DWORD dwSize = 4096, dwRet;
IP_ADAPTER_ADDRESSES *pAdapterAddresses = nullptr, *adapter; IP_ADAPTER_ADDRESSES *pAdapterAddresses = nullptr, *adapter;
char szAdapterName[256]; char szAdapterName[256];
@ -487,7 +487,7 @@ _llarp_nt_getadaptersaddresses_nametoindex(const char* ifname)
for(unsigned i = 3; i; i--) for(unsigned i = 3; i; i--)
{ {
pAdapterAddresses = (IP_ADAPTER_ADDRESSES*)_llarp_nt_heap_alloc(dwSize); pAdapterAddresses = (IP_ADAPTER_ADDRESSES*)_llarp_nt_heap_alloc(dwSize);
dwRet = GetAdaptersAddresses( dwRet = GetAdaptersAddresses(
AF_UNSPEC, AF_UNSPEC,
GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_DNS_SERVER GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_DNS_SERVER
| GAA_FLAG_SKIP_FRIENDLY_NAME | GAA_FLAG_SKIP_MULTICAST, | GAA_FLAG_SKIP_FRIENDLY_NAME | GAA_FLAG_SKIP_MULTICAST,
@ -524,7 +524,8 @@ _llarp_nt_getadaptersaddresses_nametoindex(const char* ifname)
{ {
if(0 == strcmp(szAdapterName, adapter->AdapterName)) if(0 == strcmp(szAdapterName, adapter->AdapterName))
{ {
//ifIndex = AF_INET6 == iffamily ? adapter->Ipv6IfIndex : adapter->IfIndex; // ifIndex = AF_INET6 == iffamily ? adapter->Ipv6IfIndex :
// adapter->IfIndex;
_llarp_nt_heap_free(pAdapterAddresses); _llarp_nt_heap_free(pAdapterAddresses);
return ifIndex; return ifIndex;
} }

@ -41,6 +41,18 @@ namespace llarp
return 0; return 0;
} }
size_t
PathSet::NumPathsExistingAt(llarp_time_t futureTime) const
{
size_t num = 0;
for(const auto & item : m_Paths)
{
if(!item.second->Expired(futureTime))
++num;
}
return num;
}
void void
PathSet::Tick(llarp_time_t now, llarp_router* r) PathSet::Tick(llarp_time_t now, llarp_router* r)
{ {

@ -335,7 +335,7 @@ namespace llarp
// Queue is full. // Queue is full.
assert(state == ElementState::Reading); assert(state == ElementState::Reading);
assert( assert(
1 == (circularDifference(currGen, elemGen, m_maxGeneration) + 1)); 1 == (circularDifference(currGen, elemGen, m_maxGeneration + 1)));
return QueueReturn::QueueEmpty; return QueueReturn::QueueEmpty;
} }

@ -70,7 +70,7 @@ namespace llarp
public: public:
static constexpr size_t Alignment = 64; static constexpr size_t Alignment = 64;
using AtomicIndex = std::atomic<std::uint32_t>; using AtomicIndex = std::atomic< std::uint32_t >;
private: private:
AtomicIndex m_pushIndex; // Index in the buffer that the next AtomicIndex m_pushIndex; // Index in the buffer that the next
@ -90,7 +90,7 @@ namespace llarp
const uint32_t m_maxCombinedIndex; // Maximum combined value of index and const uint32_t m_maxCombinedIndex; // Maximum combined value of index and
// generation for this object. // generation for this object.
std::atomic<std::uint32_t>* m_states; // Array of index states. std::atomic< std::uint32_t >* m_states; // Array of index states.
AtomicIndex& AtomicIndex&
pushIndex(); pushIndex();

@ -121,9 +121,10 @@ llarp_router_try_connect(struct llarp_router *router,
} }
void void
llarp_router::HandleLinkSessionEstablished(llarp::RouterContact rc) llarp_router::HandleLinkSessionEstablished(llarp::RouterContact rc,
llarp::ILinkLayer *link)
{ {
async_verify_RC(rc); async_verify_RC(rc, link);
} }
llarp_router::llarp_router() llarp_router::llarp_router()
@ -162,13 +163,7 @@ llarp_router::PersistSessionUntil(const llarp::RouterID &remote,
llarp_time_t until) llarp_time_t until)
{ {
llarp::LogDebug("persist session to ", remote, " until ", until); llarp::LogDebug("persist session to ", remote, " until ", until);
if(m_PersistingSessions.find(remote) == m_PersistingSessions.end()) m_PersistingSessions[remote] = std::max(until, m_PersistingSessions[remote]);
m_PersistingSessions[remote] = until;
else
{
if(m_PersistingSessions[remote] < until)
m_PersistingSessions[remote] = until;
}
} }
constexpr size_t MaxPendingSendQueueSize = 8; constexpr size_t MaxPendingSendQueueSize = 8;
@ -240,9 +235,15 @@ llarp_router::HandleDHTLookupForSendTo(
{ {
if(results.size()) if(results.size())
{ {
llarp_nodedb_put_rc(nodedb, results[0]); if(whitelistRouters && lokinetRouters.find(remote) == lokinetRouters.end())
llarp_router_try_connect(this, results[0], 10); {
async_verify_RC(results[0]); return;
}
if(results[0].Verify(&crypto))
{
llarp_nodedb_put_rc(nodedb, results[0]);
llarp_router_try_connect(this, results[0], 10);
}
} }
else else
{ {
@ -362,7 +363,7 @@ llarp_router::on_verify_client_rc(llarp_async_verify_rc *job)
llarp::PubKey pk(job->rc.pubkey); llarp::PubKey pk(job->rc.pubkey);
router->FlushOutboundFor(pk, router->GetLinkWithSessionByPubkey(pk)); router->FlushOutboundFor(pk, router->GetLinkWithSessionByPubkey(pk));
delete ctx; delete ctx;
delete job; router->pendingVerifyRC.erase(pk);
} }
void void
@ -374,15 +375,15 @@ llarp_router::on_verify_server_rc(llarp_async_verify_rc *job)
llarp::PubKey pk(job->rc.pubkey); llarp::PubKey pk(job->rc.pubkey);
if(!job->valid) if(!job->valid)
{ {
llarp::LogWarn("invalid server RC");
if(ctx->establish_job) if(ctx->establish_job)
{ {
// was an outbound attempt // was an outbound attempt
ctx->establish_job->Failed(); ctx->establish_job->Failed();
} }
delete ctx; delete ctx;
delete job;
router->DiscardOutboundFor(pk); router->DiscardOutboundFor(pk);
router->pendingVerifyRC.erase(pk);
return; return;
} }
// we're valid, which means it's already been committed to the nodedb // we're valid, which means it's already been committed to the nodedb
@ -412,7 +413,7 @@ llarp_router::on_verify_server_rc(llarp_async_verify_rc *job)
else else
router->FlushOutboundFor(pk, router->GetLinkWithSessionByPubkey(pk)); router->FlushOutboundFor(pk, router->GetLinkWithSessionByPubkey(pk));
delete ctx; delete ctx;
delete job; router->pendingVerifyRC.erase(pk);
} }
void void
@ -473,9 +474,11 @@ llarp_router::HandleDHTLookupForTryEstablishTo(
} }
for(const auto &result : results) for(const auto &result : results)
{ {
if(whitelistRouters
&& lokinetRouters.find(result.pubkey) == lokinetRouters.end())
continue;
llarp_nodedb_put_rc(nodedb, result); llarp_nodedb_put_rc(nodedb, result);
llarp_router_try_connect(this, result, 10); llarp_router_try_connect(this, result, 10);
async_verify_RC(result);
} }
} }
@ -537,6 +540,8 @@ llarp_router::Tick()
} }
paths.TickPaths(now); paths.TickPaths(now);
exitContext.Tick(now); exitContext.Tick(now);
if(rpcCaller)
rpcCaller->Tick(now);
} }
void void
@ -606,19 +611,21 @@ llarp_router::GetLinkWithSessionByPubkey(const llarp::RouterID &pubkey)
} }
void void
llarp_router::FlushOutboundFor(const llarp::RouterID remote, llarp_router::FlushOutboundFor(llarp::RouterID remote,
llarp::ILinkLayer *chosen) llarp::ILinkLayer *chosen)
{ {
llarp::LogDebug("Flush outbound for ", remote); llarp::LogDebug("Flush outbound for ", remote);
pendingEstablishJobs.erase(remote);
auto itr = outboundMessageQueue.find(remote); auto itr = outboundMessageQueue.find(remote);
if(itr == outboundMessageQueue.end()) if(itr == outboundMessageQueue.end())
{ {
pendingEstablishJobs.erase(remote);
return; return;
} }
if(!chosen) if(!chosen)
{ {
DiscardOutboundFor(remote); DiscardOutboundFor(remote);
pendingEstablishJobs.erase(remote);
return; return;
} }
while(itr->second.size()) while(itr->second.size())
@ -630,6 +637,7 @@ llarp_router::FlushOutboundFor(const llarp::RouterID remote,
itr->second.pop(); itr->second.pop();
} }
pendingEstablishJobs.erase(remote);
} }
void void
@ -654,9 +662,21 @@ llarp_router::GetRandomConnectedRouter(llarp::RouterContact &result) const
} }
void void
llarp_router::async_verify_RC(const llarp::RouterContact &rc) llarp_router::async_verify_RC(const llarp::RouterContact &rc,
llarp::ILinkLayer *link)
{ {
llarp_async_verify_rc *job = new llarp_async_verify_rc(); if(pendingVerifyRC.count(rc.pubkey))
return;
if(rc.IsPublicRouter() && whitelistRouters)
{
if(lokinetRouters.find(rc.pubkey) == lokinetRouters.end())
{
llarp::LogInfo(rc.pubkey, " is NOT a valid service node, rejecting");
link->CloseSessionTo(rc.pubkey);
return;
}
}
llarp_async_verify_rc *job = &pendingVerifyRC[rc.pubkey];
llarp::async_verify_context *ctx = new llarp::async_verify_context(); llarp::async_verify_context *ctx = new llarp::async_verify_context();
ctx->router = this; ctx->router = this;
ctx->establish_job = nullptr; ctx->establish_job = nullptr;
@ -679,25 +699,8 @@ llarp_router::async_verify_RC(const llarp::RouterContact &rc)
job->hook = &llarp_router::on_verify_server_rc; job->hook = &llarp_router::on_verify_server_rc;
else else
job->hook = &llarp_router::on_verify_client_rc; job->hook = &llarp_router::on_verify_client_rc;
if(rpcCaller && rc.IsPublicRouter())
{ llarp_nodedb_async_verify(job);
rpcCaller->VerifyRouter(rc.pubkey, [job](llarp::PubKey pk, bool valid) {
if(valid)
{
llarp::LogDebug("lokid says ", pk, " is valid");
llarp_nodedb_async_verify(job);
}
else
{
llarp::LogDebug("lokid says ", pk, " is NOT valid");
job->hook(job);
}
});
}
else
{
llarp_nodedb_async_verify(job);
}
} }
void void
@ -1236,6 +1239,17 @@ namespace llarp
llarp::LogWarn("failed to load hidden service config for ", key); llarp::LogWarn("failed to load hidden service config for ", key);
} }
} }
else if(StrEq(section, "lokid"))
{
if(StrEq(key, "enabled"))
{
self->whitelistRouters = IsTrueValue(val);
}
if(StrEq(key, "jsonrpc"))
{
self->lokidRPCAddr = val;
}
}
else if(StrEq(section, "dns")) else if(StrEq(section, "dns"))
{ {
if(StrEq(key, "upstream")) if(StrEq(key, "upstream"))

@ -134,7 +134,7 @@ struct llarp_router
llarp::Profiling routerProfiling; llarp::Profiling routerProfiling;
std::string routerProfilesFile = "profiles.dat"; std::string routerProfilesFile = "profiles.dat";
typedef std::queue< std::vector< byte_t > > MessageQueue; using MessageQueue = std::queue< std::vector< byte_t > >;
/// outbound message queue /// outbound message queue
std::unordered_map< llarp::RouterID, MessageQueue, llarp::RouterID::Hash > std::unordered_map< llarp::RouterID, MessageQueue, llarp::RouterID::Hash >
@ -150,6 +150,11 @@ struct llarp_router
llarp::RouterID::Hash > llarp::RouterID::Hash >
pendingEstablishJobs; pendingEstablishJobs;
// pending RCs to be verified by pubkey
std::unordered_map< llarp::RouterID, llarp_async_verify_rc,
llarp::RouterID::Hash >
pendingVerifyRC;
// sessions to persist -> timestamp to end persist at // sessions to persist -> timestamp to end persist at
std::unordered_map< llarp::RouterID, llarp_time_t, llarp::RouterID::Hash > std::unordered_map< llarp::RouterID, llarp_time_t, llarp::RouterID::Hash >
m_PersistingSessions; m_PersistingSessions;
@ -162,7 +167,8 @@ struct llarp_router
llarp_router(); llarp_router();
~llarp_router(); ~llarp_router();
void HandleLinkSessionEstablished(llarp::RouterContact); void
HandleLinkSessionEstablished(llarp::RouterContact, llarp::ILinkLayer *);
bool bool
HandleRecvLinkMessageBuffer(llarp::ILinkSession *from, llarp_buffer_t msg); HandleRecvLinkMessageBuffer(llarp::ILinkSession *from, llarp_buffer_t msg);
@ -245,8 +251,7 @@ struct llarp_router
/// manually flush outbound message queue for just 1 router /// manually flush outbound message queue for just 1 router
void void
FlushOutboundFor(const llarp::RouterID remote, FlushOutboundFor(llarp::RouterID remote, llarp::ILinkLayer *chosen = nullptr);
llarp::ILinkLayer *chosen = nullptr);
/// manually discard all pending messages to remote router /// manually discard all pending messages to remote router
void void
@ -296,7 +301,7 @@ struct llarp_router
GetRandomConnectedRouter(llarp::RouterContact &result) const; GetRandomConnectedRouter(llarp::RouterContact &result) const;
void void
async_verify_RC(const llarp::RouterContact &rc); async_verify_RC(const llarp::RouterContact &rc, llarp::ILinkLayer *link);
void void
HandleDHTLookupForSendTo(llarp::RouterID remote, HandleDHTLookupForSendTo(llarp::RouterID remote,

@ -21,11 +21,31 @@ namespace llarp
{ {
} }
virtual bool
HandleJSONResult(const ::abyss::json::Value& val) = 0;
bool
HandleResponse(::abyss::http::RPC_Response response)
{
if(!response.IsObject())
{
return HandleJSONResult({});
}
const auto itr = response.FindMember("result");
if(itr == response.MemberEnd())
{
return HandleJSONResult({});
}
if(itr->value.IsObject())
return HandleJSONResult(itr->value);
return false;
}
void void
PopulateReqHeaders(abyss::http::Headers_t& hdr) PopulateReqHeaders(abyss::http::Headers_t& hdr)
{ {
(void)hdr; (void)hdr;
// TODO: add http auth // TODO: add http auth (?)
} }
}; };
@ -45,17 +65,44 @@ namespace llarp
} }
bool bool
HandleResponse(const ::abyss::http::RPC_Response& response) HandleJSONResult(const ::abyss::json::Value& result) override
{ {
(void)response;
// TODO: get keys from response
PubkeyList_t keys; PubkeyList_t keys;
if(!result.IsObject())
{
handler({}, false);
return false;
}
const auto itr = result.FindMember("keys");
if(itr == result.MemberEnd())
{
handler({}, false);
return false;
}
if(!itr->value.IsArray())
{
handler({}, false);
return false;
}
auto key_itr = itr->value.Begin();
while(key_itr != itr->value.End())
{
if(key_itr->IsString())
{
keys.emplace_back();
if(!HexDecode(key_itr->GetString(), keys.back(), PUBKEYSIZE))
{
keys.pop_back();
}
}
++key_itr;
}
handler(keys, true); handler(keys, true);
return true; return true;
} }
void void
HandleError() HandleError() override
{ {
handler({}, false); handler({}, false);
} }
@ -73,9 +120,8 @@ namespace llarp
} }
void void
Tick() Tick(llarp_time_t now)
{ {
llarp_time_t now = router->Now();
if(now >= m_NextKeyUpdate) if(now >= m_NextKeyUpdate)
{ {
AsyncUpdatePubkeyList(); AsyncUpdatePubkeyList();
@ -90,7 +136,7 @@ namespace llarp
llarp::LogInfo("Updating service node list"); llarp::LogInfo("Updating service node list");
::abyss::json::Value params; ::abyss::json::Value params;
params.SetObject(); params.SetObject();
QueueRPC("get_all_service_node_keys", std::move(params), QueueRPC("/get_all_service_node_keys", std::move(params),
std::bind(&CallerImpl::NewAsyncUpdatePubkeyListConn, this, std::bind(&CallerImpl::NewAsyncUpdatePubkeyListConn, this,
std::placeholders::_1)); std::placeholders::_1));
} }
@ -110,21 +156,6 @@ namespace llarp
std::placeholders::_1, std::placeholders::_2)); std::placeholders::_1, std::placeholders::_2));
} }
void
VerifyRouter(llarp::PubKey pk,
std::function< void(llarp::PubKey, bool) > handler)
{
if(router->whitelistRouters)
{
auto itr = router->lokinetRouters.find(pk);
handler(pk, itr != router->lokinetRouters.end());
}
else
{
handler(pk, true);
}
}
void void
HandleServiceNodeListUpdated(const PubkeyList_t& list, bool updated) HandleServiceNodeListUpdated(const PubkeyList_t& list, bool updated)
{ {
@ -132,7 +163,7 @@ namespace llarp
{ {
router->lokinetRouters.clear(); router->lokinetRouters.clear();
for(const auto& pk : list) for(const auto& pk : list)
router->lokinetRouters.emplace( router->lokinetRouters.insert(
std::make_pair(pk, std::numeric_limits< llarp_time_t >::max())); std::make_pair(pk, std::numeric_limits< llarp_time_t >::max()));
llarp::LogInfo("updated service node list, we have ", llarp::LogInfo("updated service node list, we have ",
router->lokinetRouters.size(), " authorized routers"); router->lokinetRouters.size(), " authorized routers");
@ -301,16 +332,9 @@ namespace llarp
} }
void void
Tick() Tick(llarp_time_t now)
{
}
void
VerifyRouter(llarp::PubKey pk,
std::function< void(llarp::PubKey, bool) > result)
{ {
// always allow routers when not using libabyss (void)now;
result(pk, true);
} }
}; };
@ -332,10 +356,9 @@ namespace llarp
} }
void void
Caller::VerifyRouter(llarp::PubKey pk, Caller::Tick(llarp_time_t now)
std::function< void(llarp::PubKey, bool) > handler)
{ {
m_Impl->VerifyRouter(pk, handler); m_Impl->Tick(now);
} }
Server::Server(llarp_router* r) : m_Impl(new ServerImpl(r)) Server::Server(llarp_router* r) : m_Impl(new ServerImpl(r))

@ -94,7 +94,7 @@ namespace llarp
llarp::LogWarn("could not publish descriptors for endpoint ", Name(), llarp::LogWarn("could not publish descriptors for endpoint ", Name(),
" because we couldn't get enough valid introductions"); " because we couldn't get enough valid introductions");
if(ShouldBuildMore(now) || forceRebuild) if(ShouldBuildMore(now) || forceRebuild)
ManualRebuild(1, llarp::path::ePathRoleInboundHS); ManualRebuild(1);
return; return;
} }
m_IntroSet.I.clear(); m_IntroSet.I.clear();
@ -197,7 +197,7 @@ namespace llarp
continue; continue;
byte_t tmp[1024] = {0}; byte_t tmp[1024] = {0};
auto buf = StackBuffer< decltype(tmp) >(tmp); auto buf = StackBuffer< decltype(tmp) >(tmp);
if(!SendToOrQueue(introset.A.Addr(), buf, eProtocolText)) if(!SendToOrQueue(introset.A.Addr().data(), buf, eProtocolText))
{ {
llarp::LogWarn(Name(), " failed to send/queue data to ", llarp::LogWarn(Name(), " failed to send/queue data to ",
introset.A.Addr(), " for tag ", tag.ToString()); introset.A.Addr(), " for tag ", tag.ToString());
@ -1113,9 +1113,12 @@ namespace llarp
} }
} }
// no converstation // no converstation
EnsurePathToService(remote, [](Address, OutboundContext*) {}, 5000, return EnsurePathToService(remote,
false); [](Address, OutboundContext* c) {
return false; if(c)
c->UpdateIntroSet(true);
},
5000, false);
} }
bool bool
@ -1159,7 +1162,7 @@ namespace llarp
} }
return false; return false;
} }
Build(hops, llarp::path::ePathRoleOutboundHS); Build(hops);
return true; return true;
} }
@ -1529,8 +1532,7 @@ namespace llarp
} }
} }
(void)roles; (void)roles;
return path::Builder::SelectHop(db, prev, cur, hop, return path::Builder::SelectHop(db, prev, cur, hop, roles);
llarp::path::ePathRoleOutboundHS);
} }
uint64_t uint64_t
@ -1547,8 +1549,7 @@ namespace llarp
{ {
if(markedBad) if(markedBad)
return false; return false;
bool should = path::Builder::ShouldBuildMoreForRoles( bool should = path::Builder::ShouldBuildMore(now);
now, llarp::path::ePathRoleOutboundHS);
// determinte newest intro // determinte newest intro
Introduction intro; Introduction intro;
if(!GetNewestIntro(intro)) if(!GetNewestIntro(intro))

@ -10,8 +10,8 @@ namespace llarp
{ {
namespace thread namespace thread
{ {
typedef util::Mutex mtx_t; using mtx_t = util::Mutex;
typedef util::Lock lock_t; using lock_t = util::Lock;
using Pool = ThreadPool; using Pool = ThreadPool;

@ -4,4 +4,7 @@
if [ "X$1" = "X" ] ; then url="https://i2p.rocks/i2procks.signed" ; else url="$1" ; fi if [ "X$1" = "X" ] ; then url="https://i2p.rocks/i2procks.signed" ; else url="$1" ; fi
echo "downloading $url" echo "downloading $url"
wget -O $HOME/.lokinet/bootstrap.signed "$url" || echo "failed to download bootstrap from $url" if [ ! -d $HOME/.lokinet/]; then
mkdir $HOME/.lokinet
fi
wget -O $HOME/.lokinet/bootstrap.signed "$url" || echo "failed to download bootstrap from $url"

@ -102,8 +102,7 @@ struct ClientHandler : public abyss::http::IRPCClientHandler
} }
bool bool
HandleResponse(__attribute__((unused)) HandleResponse(__attribute__((unused)) abyss::http::RPC_Response response)
const abyss::http::RPC_Response& response)
{ {
test->Stop(); test->Stop();
return true; return true;

@ -82,7 +82,7 @@ popFrontTester(Args& args)
args.startCond.notify_one(); args.startCond.notify_one();
args.runCond.wait(guard, [&args]() { return args.runSignal; }); args.runCond.wait(guard, [&args]() { return !!args.runSignal; });
} }
for(;;) for(;;)
@ -104,7 +104,7 @@ pushBackTester(Args& args)
args.startCond.notify_one(); args.startCond.notify_one();
args.runCond.wait(guard, [&args]() { return args.runSignal; }); args.runCond.wait(guard, [&args]() { return !!args.runSignal; });
} }
for(size_t i = 0; i < args.iterations; ++i) for(size_t i = 0; i < args.iterations; ++i)
@ -322,7 +322,7 @@ TEST(TestQueue, manyProducerManyConsumer)
{ {
threads[i] = std::thread(std::bind(&popFrontTester, std::ref(args))); threads[i] = std::thread(std::bind(&popFrontTester, std::ref(args)));
args.startCond.wait(lock, [&args, i]() { return args.count == (i + 1); }); args.startCond.wait(lock, [&]() { return args.count == (i + 1); });
} }
for(size_t i = 0; i < numThreads; ++i) for(size_t i = 0; i < numThreads; ++i)
@ -330,8 +330,8 @@ TEST(TestQueue, manyProducerManyConsumer)
threads[i + numThreads] = threads[i + numThreads] =
std::thread(std::bind(&pushBackTester, std::ref(args))); std::thread(std::bind(&pushBackTester, std::ref(args)));
args.startCond.wait( args.startCond.wait(lock,
lock, [&args, i]() { return args.count == (numThreads + i + 1); }); [&]() { return args.count == (numThreads + i + 1); });
} }
args.runSignal++; args.runSignal++;

@ -139,7 +139,8 @@ struct QueueData
std::uint32_t* m_states; // Array of index states. std::uint32_t* m_states; // Array of index states.
}; };
static_assert(sizeof(QueueData) == sizeof(QueueManager)); static_assert(sizeof(QueueData) == sizeof(QueueManager),
"QueueData not updated");
static constexpr uint32_t GENERATION_COUNT_SHIFT = 0x2; static constexpr uint32_t GENERATION_COUNT_SHIFT = 0x2;
static constexpr uint32_t ELEMENT_STATE_MASK = 0x3; static constexpr uint32_t ELEMENT_STATE_MASK = 0x3;

Loading…
Cancel
Save