diff --git a/app/src/main/assets/Error/error-dark.html b/app/src/main/assets/Error/error-dark.html
new file mode 100644
index 00000000..da2e1585
--- /dev/null
+++ b/app/src/main/assets/Error/error-dark.html
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/assets/Homepage/javascript/enum-homepage.js b/app/src/main/assets/Homepage/javascript/enum-homepage.js
index 5a5f9694..d2ec8a3d 100644
--- a/app/src/main/assets/Homepage/javascript/enum-homepage.js
+++ b/app/src/main/assets/Homepage/javascript/enum-homepage.js
@@ -3,6 +3,7 @@
var Commands = {
onLoadReferenceWebsites : "onLoadReferenceWebsites",
+ onClickReferenceWebsite : "onClickReferenceWebsite"
};
/*Links*/
diff --git a/app/src/main/assets/Homepage/javascript/js-homepage-dark.js b/app/src/main/assets/Homepage/javascript/js-homepage-dark.js
new file mode 100644
index 00000000..b1fdf51b
--- /dev/null
+++ b/app/src/main/assets/Homepage/javascript/js-homepage-dark.js
@@ -0,0 +1,79 @@
+
+/*Homepage Classes*/
+
+class homepage {
+
+ mLastLinkID = "";
+
+ constructor() {
+ }
+
+ /*Helper Methods*/
+
+ onLoadReferenceWebsites(){
+ document.getElementById('mReferenceWebsites').className = 'hide';
+ }
+
+ onLoadReferenceWebsiteContent(mJson){
+ var mResponseJson = mJson;
+ var mOBJ = JSON.parse(mResponseJson);
+ var mReferenceHTML = strings.emptyString;
+
+ var mIDCounter = 0;
+ Object.keys(mOBJ).forEach(function(key) {
+ var mObject = mOBJ[key];
+ mReferenceHTML += '
'+mObject[ReferenceWebsitesDataID.mBody]+'
'
+ mIDCounter+=1;
+ });
+
+
+ var mReferenceID = document.getElementById(UIID.mReferenceWebsites);
+ mReferenceID.innerHTML = mReferenceHTML;
+
+ document.getElementById('mReferenceWebsites').className = 'show';
+ }
+
+ onLoadStaticWebpage(pData){
+ if(this.mLastLinkID.localeCompare("") != 0){
+ document.getElementById(this.mLastLinkID).style.backgroundColor = "#1c1b21";
+ }
+
+ document.getElementById(pData[0]).style.backgroundColor = "#0c0b0e";
+ window.open(pData[1],"_self");
+ this.mLastLinkID = pData[0];
+ }
+
+ /*Ajax Request*/
+
+ onParseReferenceWebsites() {
+ var $_GET=[];
+ decodeURIComponent(window.location.href).replace(/[?&]+([^=&]+)=([^&]*)/gi,function(a,name,value){$_GET[name]=value;});
+
+ setTimeout(mHomepageLoader.onLoadReferenceWebsites, 500);
+ setTimeout(mHomepageLoader.onLoadReferenceWebsiteContent, 1000, $_GET[GET.pData]);
+ }
+
+}
+
+let mHomepageLoader = new homepage();
+
+/*Helper Classes Manager*/
+function onTriggerScriptHandler(pCommand,pData) {
+ if(pCommand == Commands.onLoadReferenceWebsites){
+ mHomepageLoader.onParseReferenceWebsites()
+ }
+ else if(pCommand == Commands.onClickReferenceWebsite){
+ mHomepageLoader.onLoadStaticWebpage(pData)
+ }
+}
+
+/*Default Loaders*/
+$(window).on('load', function() {
+ /* For Local Testing */
+
+ // var mResponseJson = '[{ "mIcon":"https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196", "mHeader":"Experience", "mBody":"Donec id elit non mi porta gravida at eget metus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui"},{ "mIcon":"https://wikileaks.org/static/img/wl-logo.png", "mHeader":"Experience", "mBody":"Donec id elit non mi porta gravida at eget metus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui"},{ "mIcon":"https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196", "mHeader":"Experience", "mBody":"Donec id elit non mi porta gravida at eget metus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui"},{ "mIcon":"https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196", "mHeader":"Experience", "mBody":"Donec id elit non mi porta gravida at eget metus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui"},{ "mIcon":"https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196", "mHeader":"Experience", "mBody":"Donec id elit non mi porta gravida at eget metus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui"},{ "mIcon":"https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196", "mHeader":"Experience", "mBody":"Donec id elit non mi porta gravida at eget metus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui"}]';
+ // setTimeout(mHomepageLoader.onLoadReferenceWebsites, 500);
+ // setTimeout(mHomepageLoader.onLoadReferenceWebsiteContent, 1000, mResponseJson);
+
+ onTriggerScriptHandler(Commands.onLoadReferenceWebsites, null)
+});
diff --git a/app/src/main/assets/Homepage/javascript/js-homepage.js b/app/src/main/assets/Homepage/javascript/js-homepage.js
index 5e8ebcc1..64404f8b 100644
--- a/app/src/main/assets/Homepage/javascript/js-homepage.js
+++ b/app/src/main/assets/Homepage/javascript/js-homepage.js
@@ -3,6 +3,8 @@
class homepage {
+ mLastLinkID = "";
+
constructor() {
}
@@ -14,12 +16,14 @@ class homepage {
onLoadReferenceWebsiteContent(mJson){
var mResponseJson = mJson;
- var obj = JSON.parse(mResponseJson);
+ var mOBJ = JSON.parse(mResponseJson);
var mReferenceHTML = strings.emptyString;
- Object.keys(obj).forEach(function(key) {
- var mObject = obj[key];
- mReferenceHTML += '
'+mObject[ReferenceWebsitesDataID.mBody]+'
'
+ var mIDCounter = 0;
+ Object.keys(mOBJ).forEach(function(key) {
+ var mObject = mOBJ[key];
+ mReferenceHTML += '
'+mObject[ReferenceWebsitesDataID.mBody]+'
'
+ mIDCounter+=1;
});
@@ -29,6 +33,16 @@ class homepage {
document.getElementById('mReferenceWebsites').className = 'show';
}
+ onLoadStaticWebpage(pData){
+ if(this.mLastLinkID.localeCompare("") != 0){
+ document.getElementById(this.mLastLinkID).style.backgroundColor = "#ffffff";
+ }
+
+ document.getElementById(pData[0]).style.backgroundColor = "#f2f2f2";
+ window.open(pData[1],"_self");
+ this.mLastLinkID = pData[0];
+ }
+
/*Ajax Request*/
onParseReferenceWebsites() {
@@ -44,18 +58,22 @@ class homepage {
let mHomepageLoader = new homepage();
/*Helper Classes Manager*/
-function onTriggerScriptHandler(pCommand) {
+function onTriggerScriptHandler(pCommand,pData) {
if(pCommand == Commands.onLoadReferenceWebsites){
mHomepageLoader.onParseReferenceWebsites()
}
+ else if(pCommand == Commands.onClickReferenceWebsite){
+ mHomepageLoader.onLoadStaticWebpage(pData)
+ }
}
/*Default Loaders*/
$(window).on('load', function() {
/* For Local Testing */
- //var mResponseJson = '[{ "mIcon":"https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196", "mHeader":"Experience", "mBody":"Donec id elit non mi porta gravida at eget metus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui"},{ "mIcon":"https://wikileaks.org/static/img/wl-logo.png", "mHeader":"Experience", "mBody":"Donec id elit non mi porta gravida at eget metus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui"},{ "mIcon":"https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196", "mHeader":"Experience", "mBody":"Donec id elit non mi porta gravida at eget metus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui"},{ "mIcon":"https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196", "mHeader":"Experience", "mBody":"Donec id elit non mi porta gravida at eget metus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui"},{ "mIcon":"https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196", "mHeader":"Experience", "mBody":"Donec id elit non mi porta gravida at eget metus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui"},{ "mIcon":"https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196", "mHeader":"Experience", "mBody":"Donec id elit non mi porta gravida at eget metus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui"}]';
- //setTimeout(mHomepageLoader.onLoadReferenceWebsites, 500);
- //setTimeout(mHomepageLoader.onLoadReferenceWebsiteContent, 1000, mResponseJson);
+
+ // var mResponseJson = '[{ "mIcon":"https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196", "mHeader":"Experience", "mBody":"Donec id elit non mi porta gravida at eget metus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui"},{ "mIcon":"https://wikileaks.org/static/img/wl-logo.png", "mHeader":"Experience", "mBody":"Donec id elit non mi porta gravida at eget metus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui"},{ "mIcon":"https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196", "mHeader":"Experience", "mBody":"Donec id elit non mi porta gravida at eget metus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui"},{ "mIcon":"https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196", "mHeader":"Experience", "mBody":"Donec id elit non mi porta gravida at eget metus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui"},{ "mIcon":"https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196", "mHeader":"Experience", "mBody":"Donec id elit non mi porta gravida at eget metus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui"},{ "mIcon":"https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196", "mHeader":"Experience", "mBody":"Donec id elit non mi porta gravida at eget metus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui"}]';
+ // setTimeout(mHomepageLoader.onLoadReferenceWebsites, 500);
+ // setTimeout(mHomepageLoader.onLoadReferenceWebsiteContent, 1000, mResponseJson);
- onTriggerScriptHandler(Commands.onLoadReferenceWebsites)
+ onTriggerScriptHandler(Commands.onLoadReferenceWebsites, null)
});
diff --git a/app/src/main/assets/Homepage/style/cs-dark_header.css b/app/src/main/assets/Homepage/style/cs-dark_header.css
new file mode 100644
index 00000000..1f082895
--- /dev/null
+++ b/app/src/main/assets/Homepage/style/cs-dark_header.css
@@ -0,0 +1,76 @@
+.lh_light_background{
+ background-color: #1c1b21 !important;
+ color:#cccccc !important;
+}
+
+@media only screen and (max-width: 943px) {
+ .lh_light_header__catagory_image {
+ display : none
+ }
+}
+
+@media only screen and (max-width: 943px) {
+ .lh_light_header__catagory_bold_mobile {
+ font-weight: bold;
+ color: #cccccc !important;
+ }
+}
+
+.lh_light_header{
+ color:#000000;
+ text-align: right;
+ padding-top: 0px;
+ border-bottom-color:#000000 !important;
+ padding-top: 11px;
+ padding-bottom: 15px;
+ border-style: solid;border-right-width: 0;
+ border-left-width: 0;border-top-width: 0;
+ border-bottom-width: 1px;
+}
+
+@media only screen and (max-width: 943px) {
+ .lh_light_header {
+ border-bottom-width: 1px;
+ padding-bottom: 12px;
+ }
+}
+
+#lh_light_header_identifier {
+ background-color:#ffffff;
+}
+
+@media only screen and (max-width: 943px) {
+ #lh_light_header_identifier {
+ background-color:#ffffff;
+ }
+}
+
+.lh_light_header__bold{
+ font-weight: bold;
+ color: #1967d2 !important;
+}
+
+.lh_light_header__catagory-spacing-right{
+ margin-right: 15px;
+}
+
+.lh_light_header__catagory{
+ cursor: pointer;
+ font-size: 14px;
+ color: black;
+ padding: 13px 9px 14px;
+}
+
+/*light-header events*/
+.lh_light_header__catagory:hover{
+ color: darkslategray;
+ text-decoration: none !important;
+ border-bottom: 4px solid lightslategray;
+ background: whitesmoke;
+}
+.lh_light_header__catagory:focus{
+ color: darkslategray;
+ text-decoration: none !important;
+ border-bottom: 4px solid lightslategray;
+ background: whitesmoke;
+}
diff --git a/app/src/main/assets/Homepage/style/cs-global-properties.css b/app/src/main/assets/Homepage/style/cs-global-properties.css
index ec26ab08..1e4076b4 100644
--- a/app/src/main/assets/Homepage/style/cs-global-properties.css
+++ b/app/src/main/assets/Homepage/style/cs-global-properties.css
@@ -1,14 +1,4 @@
/*global styles*/
-.line-style {
- border: 0;
- height: 1px;
- background-image: -webkit-linear-gradient(left, #f0f0f0, #8c8b8b, #f0f0f0);
- background-image: -moz-linear-gradient(left, #f0f0f0, #8c8b8b, #f0f0f0);
- background-image: -ms-linear-gradient(left, #f0f0f0, #8c8b8b, #f0f0f0);
- background-image: -o-linear-gradient(left, #f0f0f0, #8c8b8b, #f0f0f0);
- width:40% !important;
- max-width:500px !important;
-}
/* visited link */
a:visited {
diff --git a/app/src/main/assets/Homepage/style/cs-homepage-dark.css b/app/src/main/assets/Homepage/style/cs-homepage-dark.css
new file mode 100644
index 00000000..936c69c0
--- /dev/null
+++ b/app/src/main/assets/Homepage/style/cs-homepage-dark.css
@@ -0,0 +1,329 @@
+/*Search*/
+.line-style {
+ border: 0;
+ height: 1px;
+ background-image: -webkit-linear-gradient(left, #212121, #000000, #212121);
+ background-image: -moz-linear-gradient(left, #212121, #000000, #212121);
+ background-image: -ms-linear-gradient(left, #212121, #000000, #212121);
+ background-image: -o-linear-gradient(left, #212121, #000000, #212121);
+ width:40% !important;
+ max-width:500px !important;
+}
+
+.hi_background{
+ background-color : #1c1b21 !important;
+}
+
+.clear_selection{
+ moz-user-select: none;
+ -webkit-user-select: none;
+ -ms-user-select:none;
+ user-select:none;
+ -o-user-select:none;
+}
+
+#hi_search_container {
+ margin-top:15vh;
+ margin-bottom: -25px;
+}
+
+@media only screen and (max-width: 943px) {
+ #hi_search_container {
+ margin-top:9vh;
+ }
+}
+
+.hi_logo_text{
+ max-width: 450px;
+ width: 65%;
+ height: auto;
+ display: block;
+ margin-top: -20px;
+ margin-left: auto;
+ margin-right: auto;
+ margin-bottom: 10px;
+}
+
+@media only screen and (max-width: 943px) {
+ .hp_logo_text {
+ max-width: 380px;
+ }
+}
+
+.hi_logo_image{
+ max-width: 150px;
+ width: 30%;
+ height: auto;
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+ margin-bottom: 00px;
+}
+
+@media only screen and (max-width: 943px) {
+ .hi_logo_image {
+ max-width: 100px;
+ }
+}
+
+.hi_search__logo{
+ text-align: center;
+ color: lightblue;
+ margin-bottom: -17px;
+ font-style: normal;
+ font-variant: normal;
+ line-height: 26px;
+ font-family: helvetica, monospace;
+ font-weight:bold;
+}
+
+.hi_search__search-box{
+ border-radius: 6px !important;
+ align-self: center;
+ height:42px !important;
+ outline: none;
+ color:#cccccc !important;
+ border-color: #3c3946 !important;
+ width:91% !important;
+ max-width: 575px;
+ display:block;
+ font:16px arial,sans-serif;
+ color: black;
+ padding-left:22px;
+ margin: 0 auto 5px;
+ background: #474554 !important;
+
+ box-shadow: 0 1px 1px 0 #535062;
+ -webkit-transition: .0s;
+ -moz-transition: .0s;
+ -o-transition: .0s;
+ transition: .0s;
+}
+
+.hi_reference{
+ align-self: center;
+ height:auto;
+ padding: 10px;
+ padding-bottom: 0px;
+ border-radius: 6px;
+ outline: none;
+
+ border: 1px solid #28262c;
+ box-shadow: 0 3px 3px 0 #0f0e11;
+ width:91% !important;
+ max-width: 575px;
+ display:block;
+ font:16px arial,sans-serif;
+ color: black;
+ margin: 0 auto 0px;
+ margin-top: -15px;
+ margin-bottom: 35px;
+
+ -webkit-transition: .0s;
+ -moz-transition: .0s;
+ -o-transition: .0s;
+ transition: .0s;
+}
+
+@media only screen and (max-width: 943px) {
+ .hi_search__search-box {
+ margin-top: 30px;
+ }
+}
+
+.hi_search__search-box:hover {
+ box-shadow: 0 4px 4px -1.5px #1c1b21;
+ -webkit-transition: .07s linear 0s;
+ -moz-transition: .07s linear 0s;
+ -o-transition: .07s linear 0s;
+ transition: .07s linear 0s
+}
+
+.hi_search__search-box:focus{
+ box-shadow: 0 4px 4px -1.5px #1c1b21 !important;
+ -webkit-transition: .07s linear 0s !important;;
+ -moz-transition: .07s linear 0s !important;;
+ -o-transition: .07s linear 0s !important;;
+ transition: .07s linear 0s !important;
+}
+
+/*footer-bar style*/
+.hi_search__logo{
+ margin:0 auto;
+ display:block;
+ width: 90%;
+ max-width: 400px;
+
+}
+
+.hi_search__language-text{
+ font-size: 14px;
+ text-align:center;
+ margin-top: 25px;
+ padding-top: 3px
+}
+
+@media only screen and (max-width: 943px) {
+ .hi_search__language-text {
+ margin-top: 0px;
+ }
+}
+
+.hi_search__language-name{
+ color:#7173f8;
+}
+
+.hi_search__search-button{
+ margin-top: 12px;
+ background-color:#f2f2f2;
+ height: 35px;
+ width:110%;
+ text-align:center;
+ max-width: 130px;
+ border-width: 0;
+ color:#6c6c6c;
+ font-size: 14px;
+}
+
+@media only screen and (max-width: 943px) {
+ .hi_search__search-button {
+ width: 0;
+ height: 0;
+ visibility: hidden;
+ }
+}
+
+.hi_search__button-container{
+ display:block;
+ text-align: center;
+ width: 100% !important;
+}
+
+.hi_search__search-button--left-spacing{
+ margin-left: 0
+}
+
+/* Homepage Search Buttons */
+.hi_search__search-button:hover{
+ color : #000000;
+ background: linear-gradient(#f7f7f7,#f1f1f1);
+ border-style: solid;
+ border-width: 1px;
+ border-color:#C4C4C4;
+ border-radius: 4px;
+ cursor:pointer;
+}
+
+#hi_search_button {
+ font-size: 14px;
+}
+
+@media only screen and (max-width: 943px) {
+ #hi_search_button {
+ font-size: 13px;
+ }
+}
+#hi_lucky_button {
+ font-size: 14px;
+}
+
+@media only screen and (max-width: 943px) {
+ #hi_lucky_button {
+ font-size: 13px;
+ }
+}
+
+.hi_reference_website{
+ cursor: pointer;
+}
+
+.hi_container_size
+{
+ min-height: 100% !important;
+}
+
+@media only screen and (max-width: 943px) {
+ .hi_container_size {
+ }
+}
+
+
+.hi_loader {
+ border: 4px solid #f3f3f3;
+ border-radius: 50%;
+ border-top: 4px solid #3498db;
+ width: 30px;
+ float: left;
+ height: 30px;
+ -webkit-animation: spin 2s linear infinite; /* Safari */
+ animation: spin 2s linear infinite;
+}
+
+.hi_loader_item{
+ height:10px;
+ border-width:0;
+ color:gray;
+ background-color:#0d0d0d;
+}
+
+.hi_reference_body{
+ margin-left: 0px;
+ line-height: 18px;
+ margin-top: 15px;
+ color: #e6e6e6;
+ font-size: 14px;
+}
+
+.hi_reference_header{
+ margin-left: 50px;
+ padding-left: 10px;
+ border-left: 4px solid #161617 !important;
+ font-weight: bold;
+ font-size: 16px;
+ color: #8cb3d9;
+ height: 40px;
+ padding-top:9px;
+}
+
+.hi_image_container{
+ width: 40px;
+ height: 40px;
+ border-radius: 100px;
+ float: left;
+ background-color: #1a2f42;
+ display: flex;
+}
+
+.hi_reference_image{
+ max-width: 22px; /* Or whatever */
+ max-height: 22px; /* Or whatever */
+ margin: auto; /* Magic! */
+ border-radius: 4px;
+
+ float:left;
+ font-size: 20px;
+ color: #bfbfbf;
+ font-weight: bold;
+}
+
+line-style
+/* Safari */
+@-webkit-keyframes spin {
+ 0% { -webkit-transform: rotate(0deg); }
+ 100% { -webkit-transform: rotate(360deg); }
+}
+
+@keyframes spin {
+ 0% { transform: rotate(0deg); }
+ 100% { transform: rotate(360deg); }
+}
+
+.show {
+ opacity: 1;
+ transition: opacity 500ms;
+}
+
+.hide {
+ opacity: 0;
+ transition: opacity 350ms;
+}
\ No newline at end of file
diff --git a/app/src/main/assets/Homepage/style/cs-homepage.css b/app/src/main/assets/Homepage/style/cs-homepage.css
index aef3d58e..845c7af6 100644
--- a/app/src/main/assets/Homepage/style/cs-homepage.css
+++ b/app/src/main/assets/Homepage/style/cs-homepage.css
@@ -1,4 +1,15 @@
/*Search*/
+.line-style {
+ border: 0;
+ height: 1px;
+ background-image: -webkit-linear-gradient(left, #f0f0f0, #8c8b8b, #f0f0f0);
+ background-image: -moz-linear-gradient(left, #f0f0f0, #8c8b8b, #f0f0f0);
+ background-image: -ms-linear-gradient(left, #f0f0f0, #8c8b8b, #f0f0f0);
+ background-image: -o-linear-gradient(left, #f0f0f0, #8c8b8b, #f0f0f0);
+ width:40% !important;
+ max-width:500px !important;
+}
+
.clear_selection{
moz-user-select: none;
-webkit-user-select: none;
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/bookmarkManager/bookmarkAdapter.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/bookmarkManager/bookmarkAdapter.java
index 374129de..9d7a72a8 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/bookmarkManager/bookmarkAdapter.java
+++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/bookmarkManager/bookmarkAdapter.java
@@ -80,8 +80,6 @@ public class bookmarkAdapter extends RecyclerView.Adapter
p_model_list = mPassedList;
- int m_date_state = -1;
- int m_last_day = -1;
for(int counter = 0; counter< p_model_list.size(); counter++){
if(pFilterEnabled){
@@ -90,40 +88,6 @@ public class bookmarkAdapter extends RecyclerView.Adapter=1){
-
- if(m_date_state!=2 || m_last_day!=(int)(Math.ceil(diff/7)*7)){
- m_last_day = (int)(Math.ceil(diff/7)*7);
- this.mModelList.add(new bookmarkRowModel("Last " + m_last_day + " Days",null,-1));
- mRealID.add(m_real_counter);
- mRealIndex.add(m_real_counter);
- m_date_state = 2;
- }
- }else {
- if(m_date_state!=3){
- this.mModelList.add(new bookmarkRowModel("Older ",null,-1));
- mRealID.add(m_real_counter);
- mRealIndex.add(m_real_counter);
- m_date_state = 3;
- }
- }
-
mRealID.add(p_model_list.get(counter).getID());
mRealIndex.add(m_real_counter);
this.mModelList.add(p_model_list.get(counter));
@@ -179,7 +143,7 @@ public class bookmarkAdapter extends RecyclerView.Adapter0){
- if(mCurrentList.size()>0 && mCurrentList.get(pIndex-1).getDescription()==null && (mCurrentList.size()>pIndex+1 && mCurrentList.get(pIndex+1).getDescription()==null || mCurrentList.size()==pIndex+1)){
+ if(mCurrentList.size()>0 && (mCurrentList.size()>pIndex+1 || mCurrentList.size()==pIndex+1)){
mDateVerify = true;
}
}else {
@@ -386,11 +350,9 @@ public class bookmarkAdapter extends RecyclerView.Adapter 0){
- mPainter.setColor(ContextCompat.getColor(mContext, R.color.c_list_item_current));
+ mPainter.setColor(ContextCompat.getColor(mContext, R.color.holo_gray_light_row));
RectF background = new RectF((float) itemView.getLeft(), (float) itemView.getTop(), pDX,(float) itemView.getBottom());
pCanvas.drawRect(background, mPainter);
icon = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.dustbin);
RectF icon_dest = new RectF((float) itemView.getLeft() + width ,(float) itemView.getTop() + width,(float) itemView.getLeft()+ 2*width,(float)itemView.getBottom() - width);
pCanvas.drawBitmap(icon,null,icon_dest, mPainter);
} else {
- mPainter.setColor(ContextCompat.getColor(mContext, R.color.c_list_item_current));
+ mPainter.setColor(ContextCompat.getColor(mContext, R.color.holo_gray_light_row));
RectF background = new RectF((float) itemView.getRight() + pDX, (float) itemView.getTop(),(float) itemView.getRight(), (float) itemView.getBottom());
pCanvas.drawRect(background, mPainter);
icon = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.dustbin);
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/externalNavigationManager/externalNavigationController.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/externalNavigationManager/externalNavigationController.java
index 935d3cff..e54129c4 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/externalNavigationManager/externalNavigationController.java
+++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/externalNavigationManager/externalNavigationController.java
@@ -4,14 +4,28 @@ import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
+
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.fragment.app.FragmentActivity;
+
import com.darkweb.genesissearchengine.appManager.activityContextManager;
import com.darkweb.genesissearchengine.appManager.homeManager.homeController.homeController;
+import com.darkweb.genesissearchengine.appManager.landingManager.landingController;
+import com.darkweb.genesissearchengine.constants.constants;
+import com.darkweb.genesissearchengine.constants.status;
+import com.darkweb.genesissearchengine.helperManager.helperMethod;
import com.example.myapplication.R;
-public class externalNavigationController extends Activity {
+public class externalNavigationController extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ if(status.sSettingIsAppStarted){
+ finish();
+ Uri data = externalNavigationController.this.getIntent().getData();
+ activityContextManager.getInstance().getHomeController().onLoadURL(data.toString());
+ return;
+ }
setContentView(R.layout.home_view);
Intent intent = new Intent(this.getIntent());
intent.setClassName(this.getApplicationContext(), homeController.class.getName());
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/helpManager/helpController.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/helpManager/helpController.java
index 6bb776d1..26dc7c6a 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/helpManager/helpController.java
+++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/helpManager/helpController.java
@@ -218,7 +218,12 @@ public class helpController extends AppCompatActivity {
if(!status.sSettingIsAppStarted){
activityContextManager.getInstance().getHomeController().onStartApplication(null);
}
- activityContextManager.getInstance().getHomeController().onLoadURL(constants.CONST_GENESIS_HELP_URL_CACHE);
+
+ if(status.sTheme == enums.Theme.THEME_LIGHT || helperMethod.isDayMode(this)){
+ activityContextManager.getInstance().getHomeController().onLoadURL(constants.CONST_GENESIS_HELP_URL_CACHE);
+ }else {
+ activityContextManager.getInstance().getHomeController().onLoadURL(constants.CONST_GENESIS_HELP_URL_CACHE_DARK);
+ }
finish();
activityContextManager.getInstance().onClearStack();
}
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/historyManager/historyAdapter.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/historyManager/historyAdapter.java
index 9c69e79e..fb42857a 100755
--- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/historyManager/historyAdapter.java
+++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/historyManager/historyAdapter.java
@@ -163,8 +163,6 @@ public class historyAdapter extends RecyclerView.Adapter 0){
- mPainter.setColor(ContextCompat.getColor(mContext, R.color.c_list_item_current));
+ mPainter.setColor(ContextCompat.getColor(mContext, R.color.holo_gray_light_row));
RectF background = new RectF((float) itemView.getLeft(), (float) itemView.getTop(), pDX,(float) itemView.getBottom());
pCanvas.drawRect(background, mPainter);
icon = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.dustbin);
RectF icon_dest = new RectF((float) itemView.getLeft() + width ,(float) itemView.getTop() + width,(float) itemView.getLeft()+ 2*width,(float)itemView.getBottom() - width);
pCanvas.drawBitmap(icon,null,icon_dest, mPainter);
} else {
- mPainter.setColor(ContextCompat.getColor(mContext, R.color.c_list_item_current));
+ mPainter.setColor(ContextCompat.getColor(mContext, R.color.holo_gray_light_row));
RectF background = new RectF((float) itemView.getRight() + pDX, (float) itemView.getTop(),(float) itemView.getRight(), (float) itemView.getBottom());
pCanvas.drawRect(background, mPainter);
icon = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.dustbin);
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/geckoManager/geckoClients.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/geckoManager/geckoClients.java
index 6d9ce4d7..7974af12 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/geckoManager/geckoClients.java
+++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/geckoManager/geckoClients.java
@@ -72,7 +72,11 @@ public class geckoClients
}
public void onValidateInitializeFromStartup(){
- mSession.onValidateInitializeFromStartup();
+ boolean mStatus = mSession.onValidateInitializeFromStartup();
+ if(mStatus){
+ loadURL(mSession.getCurrentURL());
+ }
+
}
public boolean onGetInitializeFromStartup(){
@@ -184,18 +188,27 @@ public class geckoClients
public void loadURL(String url) {
if(mSession.onGetInitializeFromStartup()){
mSession.initURL(url);
- if(url.startsWith("https://boogle.store?pG") || url.endsWith("boogle.store") || url.endsWith(constants.CONST_GENESIS_DOMAIN_URL_SLASHED)){
+ if(url.startsWith("https://boogle.store/?pG") || url.startsWith("https://boogle.store?pG") || url.endsWith("boogle.store") || url.endsWith(constants.CONST_GENESIS_DOMAIN_URL_SLASHED)){
try{
mSession.initURL(constants.CONST_GENESIS_DOMAIN_URL);
- String mURL = constants.CONST_GENESIS_URL_CACHED + "?pData="+ dataController.getInstance().invokeReferenceWebsite(dataEnums.eReferenceWebsiteCommands.M_FETCH,null);
- mSession.loadUri(mURL);
+ if(status.sTheme == enums.Theme.THEME_LIGHT || helperMethod.isDayMode(context)){
+ String mURL = constants.CONST_GENESIS_URL_CACHED + "?pData="+ dataController.getInstance().invokeReferenceWebsite(dataEnums.eReferenceWebsiteCommands.M_FETCH,null);
+ mSession.loadUri(mURL);
+ }else {
+ String mURL = constants.CONST_GENESIS_URL_CACHED_DARK + "?pData="+ dataController.getInstance().invokeReferenceWebsite(dataEnums.eReferenceWebsiteCommands.M_FETCH,null);
+ mSession.loadUri(mURL);
+ }
}catch (Exception ex){
ex.printStackTrace();
}
}else if(url.contains(constants.CONST_GENESIS_HELP_URL_SUB)){
try{
mSession.initURL(constants.CONST_GENESIS_HELP_URL);
- mSession.loadUri(constants.CONST_GENESIS_HELP_URL_CACHE);
+ if(status.sTheme == enums.Theme.THEME_LIGHT || helperMethod.isDayMode(context)){
+ mSession.loadUri(constants.CONST_GENESIS_HELP_URL_CACHE);
+ }else {
+ mSession.loadUri(constants.CONST_GENESIS_HELP_URL_CACHE_DARK);
+ }
}catch (Exception ex){
ex.printStackTrace();
}
@@ -276,10 +289,6 @@ public class geckoClients
loadURL(mSession.getCurrentURL());
}
- public void onReloadStatic(){
- mSession.loadUri(mSession.getCurrentURL());
- }
-
public void manual_download(String url, AppCompatActivity context){
Uri downloadURL = Uri.parse(url);
File f = new File(url);
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/geckoManager/geckoSession.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/geckoManager/geckoSession.java
index 4fb8ed4d..07b8c77b 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/geckoManager/geckoSession.java
+++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/geckoManager/geckoSession.java
@@ -61,6 +61,7 @@ import java.util.Objects;
import javax.crypto.spec.SecretKeySpec;
import static com.darkweb.genesissearchengine.constants.constants.CONST_GENESIS_URL_CACHED;
+import static com.darkweb.genesissearchengine.constants.constants.CONST_GENESIS_URL_CACHED_DARK;
import static com.darkweb.genesissearchengine.pluginManager.pluginEnums.eMessageManager.M_LONG_PRESS_URL;
import static com.darkweb.genesissearchengine.pluginManager.pluginEnums.eMessageManager.M_LONG_PRESS_WITH_LINK;
import static com.darkweb.genesissearchengine.pluginManager.pluginEnums.eMessageManagerCallbacks.M_RATE_APPLICATION;
@@ -120,12 +121,13 @@ public class geckoSession extends GeckoSession implements GeckoSession.MediaDele
return mIsLoaded;
}
- public void onValidateInitializeFromStartup(){
+ public boolean onValidateInitializeFromStartup(){
if(!mIsLoaded){
mIsLoaded = true;
initURL(mCurrentURL);
- loadUri(mCurrentURL);
+ return true;
}
+ return false;
}
void onFileUploadRequest(int resultCode, Intent data){
@@ -276,7 +278,7 @@ public class geckoSession extends GeckoSession implements GeckoSession.MediaDele
}
public void onRedrawPixel(){
- event.invokeObserver(Arrays.asList("",mSessionID,mCurrentTitle, m_current_url_id, mTheme), dataEnums.eTabCommands.M_UPDATE_PIXEL);
+ event.invokeObserver(Arrays.asList("",mSessionID,mCurrentTitle, m_current_url_id, mTheme, false), dataEnums.eTabCommands.M_UPDATE_PIXEL);
}
/*History Delegate*/
@@ -306,11 +308,15 @@ public class geckoSession extends GeckoSession implements GeckoSession.MediaDele
if(!mCurrentTitle.equals("loading")){
m_current_url_id = (int)event.invokeObserver(Arrays.asList(mCurrentURL,mSessionID,mCurrentTitle, m_current_url_id, mTheme, this), enums.etype.on_update_history);
}
- if(newUrl.startsWith(CONST_GENESIS_URL_CACHED)){
+ if(newUrl.startsWith(CONST_GENESIS_URL_CACHED) || newUrl.startsWith(CONST_GENESIS_URL_CACHED_DARK)){
mCurrentURL = constants.CONST_GENESIS_DOMAIN_URL;
}
else if(newUrl.equals(constants.CONST_GENESIS_HELP_URL_CACHE)){
- mCurrentURL = constants.CONST_GENESIS_HELP_URL;
+ if(status.sTheme == enums.Theme.THEME_LIGHT || helperMethod.isDayMode(mContext)){
+ mCurrentURL = constants.CONST_GENESIS_HELP_URL;
+ }else {
+ mCurrentURL = constants.CONST_GENESIS_HELP_URL_CACHE_DARK;
+ }
}else {
mCurrentURL = newUrl;
}
@@ -333,7 +339,7 @@ public class geckoSession extends GeckoSession implements GeckoSession.MediaDele
public GeckoResult onLoadRequest(@NonNull GeckoSession var2, @NonNull GeckoSession.NavigationDelegate.LoadRequest var1) {
mPreviousErrorPage = false;
- if(!var1.uri.startsWith(CONST_GENESIS_URL_CACHED) && var1.uri.startsWith("https://boogle.store") && !var1.uri.contains(constants.CONST_GENESIS_LOCAL_TIME_GET_KEY) && !var1.uri.contains(constants.CONST_GENESIS_LOCAL_TIME_GET_KEY)){
+ if(!var1.uri.startsWith(CONST_GENESIS_URL_CACHED) && !var1.uri.startsWith(CONST_GENESIS_URL_CACHED_DARK) && var1.uri.startsWith("https://boogle.store") && !var1.uri.contains(constants.CONST_GENESIS_LOCAL_TIME_GET_KEY) && !var1.uri.contains(constants.CONST_GENESIS_LOCAL_TIME_GET_KEY)){
String mVerificationURL = setGenesisVerificationToken(var1.uri);
initURL(mVerificationURL);
loadUri(mVerificationURL);
@@ -362,10 +368,16 @@ public class geckoSession extends GeckoSession implements GeckoSession.MediaDele
return GeckoResult.fromValue(AllowOrDeny.DENY);
}
else if(!var1.uri.equals("about:blank")){
- if(mCurrentURL.startsWith(CONST_GENESIS_URL_CACHED)){
+ if(mCurrentURL.startsWith(CONST_GENESIS_URL_CACHED) || mCurrentURL.startsWith(CONST_GENESIS_URL_CACHED_DARK)){
mCurrentURL = constants.CONST_GENESIS_DOMAIN_URL;
}else if(mCurrentURL.equals(constants.CONST_GENESIS_HELP_URL_CACHE)){
- mCurrentURL = constants.CONST_GENESIS_HELP_URL;
+ if(status.sTheme == enums.Theme.THEME_LIGHT || helperMethod.isDayMode(mContext)){
+ mCurrentURL = constants.CONST_GENESIS_HELP_URL;
+ }else {
+ mCurrentURL = constants.CONST_GENESIS_HELP_URL_CACHE_DARK;
+ }
+ }else{
+ mCurrentURL = var1.uri;
}
event.invokeObserver(Arrays.asList(var1.uri,mSessionID), enums.etype.start_proxy);
@@ -377,7 +389,6 @@ public class geckoSession extends GeckoSession implements GeckoSession.MediaDele
if(mCurrentURL.contains("boogle.store")){
event.invokeObserver(Arrays.asList(5, mSessionID), enums.etype.progress_update_forced);
}
- mCurrentURL = var1.uri;
return GeckoResult.fromValue(AllowOrDeny.ALLOW);
}else {
@@ -423,7 +434,7 @@ public class geckoSession extends GeckoSession implements GeckoSession.MediaDele
public void onFirstContentfulPaint(@NonNull GeckoSession var1) {
isFirstPaintExecuted = true;
- if(mPreviousErrorPage || mCurrentURL.contains("boogle.store") || mCurrentURL.startsWith(CONST_GENESIS_URL_CACHED)){
+ if(mPreviousErrorPage || mCurrentURL.contains("boogle.store") || mCurrentURL.startsWith(CONST_GENESIS_URL_CACHED) || mCurrentURL.startsWith(CONST_GENESIS_URL_CACHED_DARK)){
event.invokeObserver(Arrays.asList(mCurrentURL,mSessionID,mCurrentTitle, false), enums.etype.M_ON_BANNER_UPDATE);
}else {
event.invokeObserver(Arrays.asList(mCurrentURL,mSessionID,mCurrentTitle, true), enums.etype.M_ON_BANNER_UPDATE);
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/hintManager/hintAdapter.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/hintManager/hintAdapter.java
index 857be160..2b4041cc 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/hintManager/hintAdapter.java
+++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/hintManager/hintAdapter.java
@@ -45,13 +45,10 @@ public class hintAdapter extends RecyclerView.Adapter pHintList, String pSearch){
- //mHintList.clear();
mHintList = pHintList;
- mSearch = pSearch;
notifyDataSetChanged();
}
@@ -103,12 +100,14 @@ public class hintAdapter extends RecyclerView.Adapter {
+ mHintWebIcon.setColorFilter(null);
+ mHintWebIcon.clearColorFilter();
+ mHintWebIcon.setImageTintList(null);
mHintWebIcon.setClipToOutline(true);
mHintWebIcon.setImageDrawable(mHindTypeIconTemp.getDrawable());
});
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/homeController/homeController.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/homeController/homeController.java
index 483d59c4..55c624bc 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/homeController/homeController.java
+++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/homeController/homeController.java
@@ -8,7 +8,9 @@ import android.content.ComponentCallbacks2;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.SharedPreferences;
import android.content.res.Configuration;
+import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Color;
@@ -16,6 +18,7 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
+import android.preference.PreferenceManager;
import android.speech.RecognizerIntent;
import android.text.Editable;
import android.text.TextWatcher;
@@ -88,11 +91,13 @@ import java.util.Locale;
import java.util.Objects;
import java.util.concurrent.Callable;
import static com.darkweb.genesissearchengine.constants.constants.CONST_GENESIS_URL_CACHED;
+import static com.darkweb.genesissearchengine.constants.constants.CONST_GENESIS_URL_CACHED_DARK;
import static com.darkweb.genesissearchengine.constants.enums.etype.GECKO_SCROLL_CHANGED;
import static com.darkweb.genesissearchengine.constants.enums.etype.M_INITIALIZE_TAB_LINK;
import static com.darkweb.genesissearchengine.constants.enums.etype.M_INITIALIZE_TAB_SINGLE;
import static com.darkweb.genesissearchengine.pluginManager.pluginEnums.eMessageManager.*;
import static com.darkweb.genesissearchengine.pluginManager.pluginEnums.eMessageManagerCallbacks.M_RATE_APPLICATION;
+import static java.lang.Character.isLetter;
public class homeController extends AppCompatActivity implements ComponentCallbacks2
{
@@ -165,7 +170,6 @@ public class homeController extends AppCompatActivity implements ComponentCallba
onChangeTheme();
status.initStatus();
pluginController.getInstance().onLanguageInvoke(Collections.singletonList(this), pluginEnums.eLangManager.M_ACTIVITY_CREATED);
- onInitTheme();
trueTime.getInstance().initTime();
super.onCreate(savedInstanceState);
@@ -182,6 +186,11 @@ public class homeController extends AppCompatActivity implements ComponentCallba
initLocalLanguage();
onInitResume(false);
initSuggestions();
+ initAdmob();
+ }
+
+ public void initAdmob(){
+ pluginController.getInstance().onAdsInvoke(null, pluginEnums.eAdManager.M_INITIALIZE_BANNER_ADS);
}
public void onInitBooleans(){
@@ -221,7 +230,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba
if(mTempModel!=null){
tabRowModel model = (tabRowModel)mTempModel;
if(!status.mThemeApplying){
- mHomeViewController.onUpdateSearchBar(model.getSession().getCurrentURL(), false, false);
+ mHomeViewController.onUpdateSearchBar(model.getSession().getCurrentURL(), false, false, false);
}
onLoadTab(model.getSession(),false);
onLoadURL(model.getSession().getCurrentURL());
@@ -231,7 +240,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba
}
initTabCount();
if(!status.mThemeApplying){
- mHomeViewController.onUpdateSearchBar(mGeckoClient.getSession().getCurrentURL(), false, false);
+ mHomeViewController.onUpdateSearchBar(mGeckoClient.getSession().getCurrentURL(), false, false, false);
}
status.mThemeApplying = false;
}
@@ -247,27 +256,39 @@ public class homeController extends AppCompatActivity implements ComponentCallba
}
}
- public void onInitTheme(){
+ public Context setupTheme(Context context) {
+
+ Resources res = context.getResources();
+ int mode = res.getConfiguration().uiMode;
if(status.sTheme == enums.Theme.THEME_DARK){
if(AppCompatDelegate.getDefaultNightMode() != AppCompatDelegate.MODE_NIGHT_YES){
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
+ mode = Configuration.UI_MODE_NIGHT_YES;
}
}else if(status.sTheme == enums.Theme.THEME_LIGHT){
if(AppCompatDelegate.getDefaultNightMode() != AppCompatDelegate.MODE_NIGHT_NO){
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
+ mode = Configuration.UI_MODE_NIGHT_NO;
}
}else {
if(!status.sDefaultNightMode){
if(AppCompatDelegate.getDefaultNightMode() != AppCompatDelegate.MODE_NIGHT_NO){
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
+ mode = Configuration.UI_MODE_NIGHT_NO;
}
}else {
if(AppCompatDelegate.getDefaultNightMode() != AppCompatDelegate.MODE_NIGHT_YES){
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
+ mode = Configuration.UI_MODE_NIGHT_YES;
}
}
}
+
+ Configuration config = new Configuration(res.getConfiguration());
+ config.uiMode = mode;
+ context = context.createConfigurationContext(config);
+ return context;
}
@SuppressLint("ClickableViewAccessibility")
@@ -435,9 +456,13 @@ public class homeController extends AppCompatActivity implements ComponentCallba
@Override
protected void attachBaseContext(Context base) {
+ SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(base);
+ status.sTheme = mPrefs.getInt(keys.SETTING_THEME,enums.Theme.THEME_DEFAULT);
+
Prefs.setContext(base);
orbotLocalConstants.mHomeContext = new WeakReference<>(base);
- super.attachBaseContext(LocaleHelper.onAttach(base, Prefs.getDefaultLocale()));
+ Context context = setupTheme(base);
+ super.attachBaseContext(LocaleHelper.onAttach(context, Prefs.getDefaultLocale()));
}
/*-------------------------------------------------------Helper Methods-------------------------------------------------------*/
@@ -446,9 +471,9 @@ public class homeController extends AppCompatActivity implements ComponentCallba
mGeckoClient.onGetFavIcon(pImageView, pURL);
}
- public void onGetThumbnail(ImageView pImageView){
+ public void onGetThumbnail(ImageView pImageView,boolean pLoadTabView){
mRenderedBitmap = mGeckoView.capturePixels();
- dataController.getInstance().invokeTab(dataEnums.eTabCommands.M_UPDATE_PIXEL, Arrays.asList(mGeckoClient.getSession().getSessionID(), mRenderedBitmap, pImageView, mGeckoView));
+ dataController.getInstance().invokeTab(dataEnums.eTabCommands.M_UPDATE_PIXEL, Arrays.asList(mGeckoClient.getSession().getSessionID(), mRenderedBitmap, pImageView, mGeckoView, pLoadTabView));
}
@@ -483,7 +508,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba
}
public void onLoadTab(geckoSession mTempSession, boolean isSessionClosed){
- dataController.getInstance().invokeTab(dataEnums.eTabCommands.M_UPDATE_PIXEL, Arrays.asList(mGeckoClient.getSession().getSessionID(), mRenderedBitmap, null, mGeckoView));
+ dataController.getInstance().invokeTab(dataEnums.eTabCommands.M_UPDATE_PIXEL, Arrays.asList(mGeckoClient.getSession().getSessionID(), mRenderedBitmap, null, mGeckoView, false));
if(!isSessionClosed){
dataController.getInstance().invokeTab(dataEnums.eTabCommands.MOVE_TAB_TO_TOP, Collections.singletonList(mTempSession));
@@ -494,7 +519,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba
mGeckoView.setSession(mTempSession);
mHomeViewController.onClearSelections(false);
- mHomeViewController.onUpdateSearchBar(mTempSession.getCurrentURL(),false,true);
+ mHomeViewController.onUpdateSearchBar(mTempSession.getCurrentURL(),false,true, false);
if(mTempSession.getProgress()>0 && mTempSession.getProgress()<100){
mHomeViewController.onProgressBarUpdate(mTempSession.getProgress(), false);
}else {
@@ -504,7 +529,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba
mGeckoClient.onValidateInitializeFromStartup();
mGeckoClient.onSessionReinit();
mHomeViewController.onUpdateStatusBarTheme(mTempSession.getTheme(), false);
- mHomeViewController.onUpdateSearchBar(mGeckoClient.getSession().getCurrentURL(), false, false);
+ mHomeViewController.onUpdateSearchBar(mGeckoClient.getSession().getCurrentURL(), false, false, false);
mHomeViewController.onUpdateStatusBarTheme(mGeckoClient.getSession().getTheme(),true);
mAppBar.setExpanded(true,true);
mRenderedBitmap = mGeckoView.capturePixels();
@@ -618,7 +643,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba
if (actionId == EditorInfo.IME_ACTION_NEXT || actionId == EditorInfo.IME_ACTION_GO || actionId == EditorInfo.IME_ACTION_DONE)
{
onSearchBarInvoked(v);
- mHomeViewController.onUpdateSearchBar(mGeckoClient.getSession().getCurrentURL(),true,true);
+ mHomeViewController.onUpdateSearchBar(mGeckoClient.getSession().getCurrentURL(),true,true, false);
mHomeViewController.onClearSelections(true);
mGeckoClient.setLoading(true);
final Handler handler = new Handler();
@@ -648,7 +673,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba
if(hasFocus)
{
pluginController.getInstance().onMessageManagerInvoke(null, M_RESET);
- mHomeViewController.onUpdateSearchBar(mGeckoClient.getSession().getCurrentURL(),false,true);
+ mHomeViewController.onUpdateSearchBar(mGeckoClient.getSession().getCurrentURL(),false,true, false);
final Handler handler = new Handler();
handler.postDelayed(() ->
@@ -668,6 +693,13 @@ public class homeController extends AppCompatActivity implements ComponentCallba
public void afterTextChanged(Editable s) {
if(status.sSearchSuggestionStatus && isSuggestionChanged){
+ String mURL = mSearchbar.getText().toString();
+
+ if(!mURL.equals(strings.GENERIC_EMPTY_STR) && isLetter(mSearchbar.getText().toString().charAt(0)) && mSearchbar.getText().toString().contains(".")){
+ mHomeViewController.onUpdateSearchIcon(2);
+ }else{
+ mHomeViewController.onUpdateSearchIcon(0);
+ }
if(!mSearchBarLoading && mSearchEngineBar.getVisibility() != View.VISIBLE){
mSuggestions = (ArrayList)dataController.getInstance().invokeSuggestions(dataEnums.eSuggestionCommands.M_GET_SUGGESTIONS, Collections.singletonList(mSearchbar.getText().toString()));
initSuggestionView(mSuggestions, s.toString());
@@ -720,7 +752,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba
}
mHomeViewController.initSearchBarFocus(false);
if(!mGeckoClient.isLoading()){
- mHomeViewController.onUpdateSearchBar(mGeckoClient.getSession().getCurrentURL(),false,true);
+ mHomeViewController.onUpdateSearchBar(mGeckoClient.getSession().getCurrentURL(),false,true, false);
}
helperMethod.hideKeyboard(homeController.this);
}
@@ -770,7 +802,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba
if(validated_url!=null){
url = validated_url;
}
- mHomeViewController.onUpdateSearchBar(url,false,true);
+ mHomeViewController.onUpdateSearchBar(url,false,true, false);
onLoadURL(url);
}
@@ -785,12 +817,12 @@ public class homeController extends AppCompatActivity implements ComponentCallba
}
onLoadURL(pURL);
- mHomeViewController.onUpdateSearchBar(pURL,false,true);
+ mHomeViewController.onUpdateSearchBar(pURL,false,true, false);
}
public void onSuggestionMove(View view){
String val = view.getTag().toString();
- mHomeViewController.onUpdateSearchBar(val,false,false);
+ mHomeViewController.onUpdateSearchBar(val,false,false, true);
}
public void applyTheme(){
@@ -832,10 +864,10 @@ public class homeController extends AppCompatActivity implements ComponentCallba
initializeGeckoView(true, true);
if(status.sOpenURLInNewTab){
onLoadURL(helperMethod.getDomainName(status.sSettingSearchStatus));
- mHomeViewController. onUpdateSearchBar(helperMethod.getDomainName(status.sSettingSearchStatus),false,true);
+ mHomeViewController. onUpdateSearchBar(helperMethod.getDomainName(status.sSettingSearchStatus),false,true, false);
}else {
onLoadURL("about:blank");
- mHomeViewController. onUpdateSearchBar(strings.HOME_BLANK_PAGE,false,true);
+ mHomeViewController. onUpdateSearchBar(strings.HOME_BLANK_PAGE,false,true, false);
mHomeViewController.onNewTab();
}
mHomeViewController.progressBarReset();
@@ -844,17 +876,17 @@ public class homeController extends AppCompatActivity implements ComponentCallba
}
public void postNewLinkTabAnimation(String url){
- dataController.getInstance().invokeTab(dataEnums.eTabCommands.M_UPDATE_PIXEL, Arrays.asList(mGeckoClient.getSession().getSessionID(), mRenderedBitmap, null, mGeckoView));
+ dataController.getInstance().invokeTab(dataEnums.eTabCommands.M_UPDATE_PIXEL, Arrays.asList(mGeckoClient.getSession().getSessionID(), mRenderedBitmap, null, mGeckoView,false));
initializeGeckoView(true, true);
mHomeViewController.progressBarReset();
- mHomeViewController.onUpdateSearchBar(url,false,true);
+ mHomeViewController.onUpdateSearchBar(url,false,true, false);
mGeckoClient.loadURL(url);
}
public void onNewTab(boolean isKeyboardOpenedTemp, boolean isKeyboardOpened){
try {
- onGetThumbnail(null);
+ onGetThumbnail(null, false);
}catch (Exception ignored){}
final Handler handler = new Handler();
@@ -868,24 +900,26 @@ public class homeController extends AppCompatActivity implements ComponentCallba
}
public void onOpenLinkNewTab(String url){
- onGetThumbnail(null);
+ onGetThumbnail(null, false);
final Handler handler = new Handler();
handler.postDelayed(() -> mHomeViewController.onNewTabAnimation(Collections.singletonList(url),M_INITIALIZE_TAB_LINK), 100);
}
public void onOpenTabViewBoundary(View view){
- onGetThumbnail(null);
+ onGetThumbnail(null, true);
mGeckoClient.onRedrawPixel();
mNewTab.setPressed(true);
}
public void onOpenTabReady(){
- runOnUiThread(() -> {
- activityContextManager.getInstance().getTabController().onInit();
- mHomeViewController.onShowTabContainer();
- overridePendingTransition(R.anim.popup_anim_in, R.anim.popup_anim_out);
- });
+ if(!status.mThemeApplying){
+ runOnUiThread(() -> {
+ activityContextManager.getInstance().getTabController().onInit();
+ mHomeViewController.onShowTabContainer();
+ overridePendingTransition(R.anim.popup_anim_in, R.anim.popup_anim_out);
+ });
+ }
}
public void onLockSecure(View view){
@@ -910,14 +944,20 @@ public class homeController extends AppCompatActivity implements ComponentCallba
}
public void onDisableTabViewController(){
+ mHomeViewController.onUpdateStatusBarTheme(mGeckoClient.getSession().getTheme(), true);
mHomeViewController.onHideTabContainer();
+ activityContextManager.getInstance().getTabController().onExitAndClearBackup();
+ activityContextManager.getInstance().getTabController().onPostExit();
}
@Override
public void onBackPressed(){
if(mTabFragment.getVisibility()==View.VISIBLE){
onResume();
+ mHomeViewController.onUpdateStatusBarTheme(mGeckoClient.getSession().getTheme(), true);
mHomeViewController.onHideTabContainer();
+ activityContextManager.getInstance().getTabController().onPostExit();
+ activityContextManager.getInstance().getTabController().onBackPressed();
return;
}
@@ -987,10 +1027,10 @@ public class homeController extends AppCompatActivity implements ComponentCallba
mHomeViewController.onSetBannerAdMargin(true,(boolean)pluginController.getInstance().onAdsInvoke(null, pluginEnums.eAdManager.M_IS_ADVERT_LOADED));
}
- if(mGeckoClient.getSession().getCurrentURL().contains("boogle.store") || mGeckoClient.getSession().getCurrentURL().startsWith(CONST_GENESIS_URL_CACHED)){
- mHomeViewController.updateBannerAdvertStatus(false);
+ if(mGeckoClient.getSession().getCurrentURL().contains("boogle.store") || mGeckoClient.getSession().getCurrentURL().startsWith(CONST_GENESIS_URL_CACHED) || mGeckoClient.getSession().getCurrentURL().startsWith(CONST_GENESIS_URL_CACHED_DARK)){
+ mHomeViewController.updateBannerAdvertStatus(false, (boolean)pluginController.getInstance().onAdsInvoke(null, pluginEnums.eAdManager.M_IS_ADVERT_LOADED));
}else {
- mHomeViewController.updateBannerAdvertStatus(true);
+ mHomeViewController.updateBannerAdvertStatus(true, (boolean)pluginController.getInstance().onAdsInvoke(null, pluginEnums.eAdManager.M_IS_ADVERT_LOADED));
}
}
if(mSplashScreen.getAlpha()>0){
@@ -1006,6 +1046,14 @@ public class homeController extends AppCompatActivity implements ComponentCallba
mHomeViewController.closeMenu();
helperMethod.hideKeyboard(this);
}
+ if(mTabFragment.getVisibility()==View.VISIBLE){
+ onResume();
+ mHomeViewController.onUpdateStatusBarTheme(mGeckoClient.getSession().getTheme(), true);
+ mHomeViewController.onHideTabContainer();
+ activityContextManager.getInstance().getTabController().onPostExit();
+ activityContextManager.getInstance().getTabController().onBackPressed();
+ return;
+ }
mGeckoClient.onExitFullScreen();
mHomeViewController.onUpdateStatusBarTheme(mGeckoClient.getSession().getTheme(), true);
@@ -1164,7 +1212,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba
}
public boolean onCloseCurrentTab(geckoSession session){
- dataController.getInstance().invokeTab(dataEnums.eTabCommands.CLOSE_TAB, Collections.singletonList(session));
+ dataController.getInstance().invokeTab(dataEnums.eTabCommands.CLOSE_TAB, Arrays.asList(session, session));
tabRowModel model = (tabRowModel)dataController.getInstance().invokeTab(dataEnums.eTabCommands.GET_CURRENT_TAB, null);
session.stop();
@@ -1172,13 +1220,13 @@ public class homeController extends AppCompatActivity implements ComponentCallba
initTabCount();
if(model!=null){
- if(activityContextManager.getInstance().getTabController()==null || activityContextManager.getInstance().getTabController()!=null && mTabFragment.getVisibility()==View.VISIBLE){
+ if(mTabFragment.getVisibility()!=View.VISIBLE){
onLoadTab(model.getSession(),true);
}
return true;
}
else {
- if(activityContextManager.getInstance().getTabController()==null || activityContextManager.getInstance().getTabController()!=null && mTabFragment.getVisibility()==View.VISIBLE){
+ if(mTabFragment.getVisibility()!=View.VISIBLE){
return false;
}else {
return true;
@@ -1199,7 +1247,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba
}
public void onClearSearchBar(View view){
- mHomeViewController.onUpdateSearchBar(strings.GENERIC_EMPTY_STR, false, true);
+ mHomeViewController.onUpdateSearchBar(strings.GENERIC_EMPTY_STR, false, true, false);
}
public void onFindNext(View view){
@@ -1400,12 +1448,12 @@ public class homeController extends AppCompatActivity implements ComponentCallba
status.sSettingRedirectStatus = strings.GENERIC_EMPTY_STR;
}else {
if(status.mThemeApplying){
- mHomeViewController.onUpdateSearchBar(data.get(0).toString(),false, false);
+ mHomeViewController.onUpdateSearchBar(data.get(0).toString(),false, false, false);
mHomeViewController.splashScreenDisableInstant();
onLoadTabOnResume();
}
onLoadURL(data.get(0).toString());
- mHomeViewController.onUpdateSearchBar(dataToStr(data.get(0),mGeckoClient.getSession().getCurrentURL()),false,true);
+ mHomeViewController.onUpdateSearchBar(dataToStr(data.get(0),mGeckoClient.getSession().getCurrentURL()),false,true, false);
}
}
else if(e_type.equals(enums.etype.ON_LOAD_TAB_ON_RESUME)){
@@ -1471,7 +1519,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba
}
mHomeViewController.initSearchBarFocus(false);
if(!mGeckoClient.isLoading()){
- mHomeViewController.onUpdateSearchBar(mGeckoClient.getSession().getCurrentURL(),false,true);
+ mHomeViewController.onUpdateSearchBar(mGeckoClient.getSession().getCurrentURL(),false,true, false);
}
helperMethod.hideKeyboard(homeController.this);
}
@@ -1503,7 +1551,10 @@ public class homeController extends AppCompatActivity implements ComponentCallba
mAppBar.setExpanded(true,true);
}
else if(e_type.equals(enums.etype.M_ON_BANNER_UPDATE)){
- mHomeViewController.updateBannerAdvertStatus((boolean)data.get(3));
+ Object mAdvertResponse = pluginController.getInstance().onAdsInvoke(null, pluginEnums.eAdManager.M_IS_ADVERT_LOADED);
+ if(mAdvertResponse != null){
+ mHomeViewController.updateBannerAdvertStatus((boolean)data.get(3), (boolean)mAdvertResponse);
+ }
}
else if(e_type.equals(enums.etype.progress_update)){
mHomeViewController.onProgressBarUpdate((int)data.get(0), false);
@@ -1512,7 +1563,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba
mHomeViewController.onProgressBarUpdate((int)data.get(0), true);
}
else if(e_type.equals(enums.etype.ON_UPDATE_SEARCH_BAR)){
- mHomeViewController.onUpdateSearchBar((String)data.get(0), false, false);
+ mHomeViewController.onUpdateSearchBar((String)data.get(0), false, false, false);
}
else if(e_type.equals(enums.etype.ON_FIRST_PAINT)){
mHomeViewController.onFirstPaint();
@@ -1524,13 +1575,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba
//mHomeViewController.onUpdateSearchBar(dataToStr(data.get(0),mGeckoClient.getSession().getCurrentURL()),false,true);
}
else if(e_type.equals(enums.etype.back_list_empty)){
- if((int)dataController.getInstance().invokeTab(dataEnums.eTabCommands.GET_TOTAL_TAB, null)>1){
- if(!onCloseCurrentTab(mGeckoClient.getSession())){
- postNewTabAnimation(true,false);
- }
- }else {
- helperMethod.onMinimizeApp(homeController.this);
- }
+ helperMethod.onMinimizeApp(homeController.this);
}
else if(e_type.equals(enums.etype.ON_UPDATE_THEME)){
mHomeViewController.onUpdateStatusBarTheme(mGeckoClient.getSession().getTheme(),false);
@@ -1545,10 +1590,6 @@ public class homeController extends AppCompatActivity implements ComponentCallba
dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_SET_BOOL, Arrays.asList(keys.SETTING_IS_BOOTSTRAPPED,true));
mHomeViewController.onPageFinished();
mGeckoClient.onRedrawPixel();
-
- final Handler handler = new Handler();
- Runnable runnable = () -> pluginController.getInstance().onAdsInvoke(null, pluginEnums.eAdManager.M_INITIALIZE_BANNER_ADS);
- handler.postDelayed(runnable, 2000);
}
else if(e_type.equals(M_RATE_APPLICATION)){
if(!status.sSettingIsAppRated){
@@ -1562,10 +1603,10 @@ public class homeController extends AppCompatActivity implements ComponentCallba
initLocalLanguage();
mHomeViewController.onPageFinished();
mGeckoClient.onRedrawPixel();
- mHomeViewController.onUpdateSearchBar(dataToStr(data.get(0),mGeckoClient.getSession().getCurrentURL()),false,true);
+ mHomeViewController.onUpdateSearchBar(dataToStr(data.get(0),mGeckoClient.getSession().getCurrentURL()),false,true, false);
}
else if(e_type.equals(enums.etype.search_update)){
- mHomeViewController.onUpdateSearchBar(dataToStr(data.get(0),mGeckoClient.getSession().getCurrentURL()),false, true);
+ mHomeViewController.onUpdateSearchBar(dataToStr(data.get(0),mGeckoClient.getSession().getCurrentURL()),false, true, false);
}
else if(e_type.equals(enums.etype.download_file_popup)){
List mData = new ArrayList<>();
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/homeController/homeViewController.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/homeController/homeViewController.java
index 18ffecb5..81dd9b0f 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/homeController/homeViewController.java
+++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/homeController/homeViewController.java
@@ -55,6 +55,9 @@ import java.util.Collections;
import java.util.List;
import java.util.concurrent.Callable;
import static android.content.Context.LAYOUT_INFLATER_SERVICE;
+import static com.darkweb.genesissearchengine.constants.constants.CONST_GENESIS_DOMAIN_URL;
+import static com.darkweb.genesissearchengine.constants.constants.CONST_GENESIS_URL_CACHED;
+import static com.darkweb.genesissearchengine.constants.constants.CONST_GENESIS_URL_CACHED_DARK;
import static org.mozilla.geckoview.GeckoSessionSettings.USER_AGENT_MODE_DESKTOP;
class homeViewController
@@ -160,7 +163,7 @@ class homeViewController
mContext.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_USER);
}, 1500);
- updateBannerAdvertStatus(false);
+ updateBannerAdvertStatus(false, false);
}
public void initTopBarPadding(){
@@ -192,20 +195,27 @@ class homeViewController
public void onShowTabContainer(){
if(mTabFragment.getAlpha()==0 || mTabFragment.getAlpha()==1){
mTabFragment.setVisibility(View.VISIBLE);
- mTabFragment.animate().setDuration(250).alpha(1);
+ mTabFragment.setTranslationY(-1 * helperMethod.pxFromDp(15));
+ mTabFragment.animate()
+ .setDuration(250)
+ .translationY(0)
+ .alpha(1f);
}
}
public void onHideTabContainer(){
if(mTabFragment.getAlpha()==1){
- mTabFragment.animate().setDuration(250).alpha(0).withEndAction(() -> mTabFragment.setVisibility(View.GONE));
+ mTabFragment.animate()
+ .setDuration(250)
+ .alpha(0f).withEndAction(() -> mTabFragment.setVisibility(View.GONE));
}
+ mEvent.invokeObserver(Collections.singletonList(status.sSettingSearchStatus), enums.etype.M_INIT_TAB_COUNT);
}
public int getSearchLogo(){
switch (status.sSettingSearchStatus) {
case constants.CONST_BACKEND_GENESIS_URL:
- return R.drawable.genesis;
+ return R.drawable.ic_genesis_vector;
case constants.CONST_BACKEND_GOOGLE_URL:
return R.drawable.google;
case constants.CONST_BACKEND_DUCK_DUCK_GO_URL:
@@ -217,17 +227,34 @@ class homeViewController
}
}
+ @SuppressLint("UseCompatLoadingForDrawables")
+ public void onUpdateSearchIcon(int mStatus){
+ try {
+ if(mStatus==0){
+ mSearchLock.setColorFilter(null);
+ mSearchLock.clearColorFilter();
+ mSearchLock.setImageTintList(null);
+ mSearchLock.setImageDrawable(mContext.getResources().getDrawable(getSearchLogo()));
+ }
+ else if(mStatus==1){
+ mSearchLock.setColorFilter(ContextCompat.getColor(mContext, R.color.c_lock_tint));
+ mSearchLock.setImageDrawable(helperMethod.getDrawableXML(mContext,R.xml.ic_baseline_lock));
+ }
+ else if(mStatus==2){
+ mSearchLock.setColorFilter(ContextCompat.getColor(mContext, R.color.c_icon_tint));
+ mSearchLock.setImageDrawable(helperMethod.getDrawableXML(mContext,R.xml.ic_baseline_browser));
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
@SuppressLint("UseCompatLoadingForDrawables")
public void initSearchBarFocus(boolean pStatus){
if(!pStatus){
this.mVoiceInput.animate().setDuration(0).alpha(0).withEndAction(() -> {
- try {
- mSearchLock.setColorFilter(ContextCompat.getColor(mContext, R.color.c_lock_tint));
- mSearchLock.setImageDrawable(helperMethod.getDrawableXML(mContext,R.xml.ic_baseline_lock));
- } catch (Exception e) {
- e.printStackTrace();
- }
+ onUpdateSearchIcon(1);
mVoiceInput.setVisibility(View.GONE);
mNewTab.setVisibility(View.VISIBLE);
mMenu.setVisibility(View.VISIBLE);
@@ -246,28 +273,10 @@ class homeViewController
});
}else {
- try {
- mSearchLock.setImageDrawable(mContext.getResources().getDrawable(getSearchLogo()));
- } catch (Exception e) {
- e.printStackTrace();
- }
- mSearchLock.setColorFilter(null);
- mSearchLock.clearColorFilter();
- mSearchLock.setImageTintList(null);
+ onUpdateSearchIcon(0);
mSearchbar.setMovementMethod(mSearchBarMovementMethod);
mSearchbar.setFadingEdgeLength(helperMethod.pxFromDp(0));
- Drawable drawable;
- Resources res = mContext.getResources();
- try {
- if(status.sSettingEnableVoiceInput){
- drawable = Drawable.createFromXml(res, res.getXml(R.xml.ic_baseline_keyboard_voice));
- }else {
- drawable = Drawable.createFromXml(res, res.getXml(R.xml.ic_search_small));
- }
- mVoiceInput.setImageDrawable(drawable);
- } catch (Exception ignored) {
- }
final Handler handler = new Handler();
handler.postDelayed(() ->
@@ -295,6 +304,25 @@ class homeViewController
}
void initTab(int count){
+ mNewTab.animate().cancel();
+ mNewTab.animate().withLayer()
+ .rotationX(60)
+ .alpha(0.4f)
+ .setDuration(80)
+ .withEndAction(
+ new Runnable() {
+ @Override public void run() {
+ // second quarter turn
+ mNewTab.setRotationX(-60);
+ mNewTab.animate().withLayer()
+ .rotationX(0)
+ .alpha(1)
+ .setDuration(100)
+ .start();
+ }
+ }
+ ).start();
+
mNewTab.setText((count+strings.GENERIC_EMPTY_STR));
}
@@ -635,8 +663,8 @@ class homeViewController
}
}
- void updateBannerAdvertStatus(boolean status){
- if(status){
+ void updateBannerAdvertStatus(boolean status, boolean pIsAdvertLoaded){
+ if(status && pIsAdvertLoaded){
if(mBannerAds.getAlpha()==0){
mBannerAds.animate().cancel();
mBannerAds.setAlpha(0);
@@ -655,8 +683,11 @@ class homeViewController
private Handler searchBarUpdateHandler = new Handler();
private String handlerLocalUrl = "";
- void onUpdateSearchBar(String url,boolean showProtocol, boolean pClearText){
- if(!mSearchbar.hasFocus() || pClearText){
+ void onUpdateSearchBar(String url,boolean showProtocol, boolean pClearText, boolean pBypassFocus){
+ if(url.equals(CONST_GENESIS_URL_CACHED) || url.equals(CONST_GENESIS_URL_CACHED_DARK)){
+ url = CONST_GENESIS_DOMAIN_URL;
+ }
+ if(!mSearchbar.hasFocus() || pClearText || pBypassFocus){
int delay = 0;
handlerLocalUrl = url;
@@ -685,7 +716,7 @@ class homeViewController
public void onUpdateStatusBarTheme(String pTheme, boolean mForced)
{
- if(mSplashScreen.getAlpha()<=0){
+ if(mSplashScreen.getAlpha()<=0 && status.sTheme != enums.Theme.THEME_DARK){
int mColor = -1;
try{
mColor = Color.parseColor(pTheme);
@@ -693,7 +724,7 @@ class homeViewController
mColor = -1;
}
- if(pTheme!=null && status.sToolbarTheme && mColor!=-1){
+ if(pTheme!=null && status.sToolbarTheme && mColor!=-1 && helperMethod.getColorDensity(mColor)<0.80){
mTopBar.setBackgroundColor(mColor);
mSearchbar.setTextColor(helperMethod.invertedGrayColor(mColor));
mSearchbar.setHintTextColor(helperMethod.invertedGrayColor(mColor));
@@ -929,10 +960,10 @@ class homeViewController
}
private int defaultFlag = 0;
- void onFullScreenUpdate(boolean status){
- int value = !status ? 1 : 0;
+ void onFullScreenUpdate(boolean pStatus){
+ int value = !pStatus ? 1 : 0;
- if(status) {
+ if(pStatus) {
isFullScreen = true;
}else {
this.mBlockerFullSceen.setVisibility(View.VISIBLE);
@@ -940,13 +971,13 @@ class homeViewController
isFullScreen = false;
}
- if(status){
+ if(pStatus){
onProgressBarUpdate(100, false);
this.mBlockerFullSceen.setVisibility(View.VISIBLE);
this.mBlockerFullSceen.setAlpha(0f);
this.mBlockerFullSceen.animate().setStartDelay(0).setDuration(200).alpha(1).withEndAction(() -> {
- mTopBar.setClickable(!status);
- disableEnableControls(!status, mTopBar);
+ mTopBar.setClickable(!pStatus);
+ disableEnableControls(!pStatus, mTopBar);
mTopBar.setAlpha(value);
mBannerAds.setVisibility(View.GONE);
@@ -976,8 +1007,8 @@ class homeViewController
});
}
else {
- mTopBar.setClickable(!status);
- disableEnableControls(!status, mTopBar);
+ mTopBar.setClickable(!pStatus);
+ disableEnableControls(!pStatus, mTopBar);
mTopBar.setAlpha(value);
mBannerAds.setVisibility(View.GONE);
@@ -994,7 +1025,11 @@ class homeViewController
initTopBarPadding();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- mContext.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
+ if(status.sTheme == enums.Theme.THEME_DARK){
+ mContext.getWindow().getDecorView().setSystemUiVisibility(0);
+ }else {
+ mContext.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
+ }
}else {
mContext.getWindow().setStatusBarColor(mContext.getResources().getColor(R.color.blue_dark));
}
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/settingManager/generalManager/settingGeneralController.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/settingManager/generalManager/settingGeneralController.java
index d6cb9b92..f75c11d9 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/settingManager/generalManager/settingGeneralController.java
+++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/settingManager/generalManager/settingGeneralController.java
@@ -210,6 +210,8 @@ public class settingGeneralController extends AppCompatActivity {
dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_SET_INT, Arrays.asList(keys.SETTING_THEME,status.sTheme));
mSettingGeneralViewController.onTrigger(settingGeneralEnums.eGeneralViewController.M_UPDATE_THEME_BLOCKER, Collections.singletonList(enums.Theme.THEME_DARK));
mIsThemeChanging = false;
+ }else {
+ mIsThemeChanging = false;
}
}else if(view.getId() == R.id.pOption2) {
if(status.sTheme != enums.Theme.THEME_LIGHT) {
@@ -219,6 +221,8 @@ public class settingGeneralController extends AppCompatActivity {
dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_SET_INT, Arrays.asList(keys.SETTING_THEME,status.sTheme));
mSettingGeneralViewController.onTrigger(settingGeneralEnums.eGeneralViewController.M_UPDATE_THEME_BLOCKER, Collections.singletonList(enums.Theme.THEME_LIGHT));
mIsThemeChanging = false;
+ }else {
+ mIsThemeChanging = false;
}
}else {
if(status.sTheme != enums.Theme.THEME_DEFAULT) {
@@ -228,6 +232,8 @@ public class settingGeneralController extends AppCompatActivity {
dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_SET_INT, Arrays.asList(keys.SETTING_THEME,status.sTheme));
mSettingGeneralViewController.onTrigger(settingGeneralEnums.eGeneralViewController.M_UPDATE_THEME_BLOCKER, Collections.singletonList(enums.Theme.THEME_DEFAULT));
mIsThemeChanging = false;
+ }else {
+ mIsThemeChanging = false;
}
}
}
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/tabManager/tabAdapter.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/tabManager/tabAdapter.java
index b6821202..b240fd86 100755
--- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/tabManager/tabAdapter.java
+++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/tabManager/tabAdapter.java
@@ -309,6 +309,9 @@ public class tabAdapter extends RecyclerView.Adapter
notifyItemChanged(mModelList.size()-1);
}
}else if(v.getId() == R.id.pRemoveRow){
+ v.setEnabled(false);
+ v.setFocusableInTouchMode(false);
+ v.setClickable(false);
for(int mCounter=0;mCounter= mListModel.getList().size()){
+ return 0;
+ }
+ else {
+ final int dragFlags = ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT;
+ final int swipeFlags = 0;
+ return makeMovementFlags(swipeFlags, dragFlags);
+ }
+ } else {
+ if((Integer) viewHolder.itemView.getTag() >= mListModel.getList().size()){
+ return 0;
+ }
+ else {
+ final int dragFlags = ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT;
+ final int swipeFlags = 0;
+ return makeMovementFlags(swipeFlags, dragFlags);
+ }
+ }
+ }
+
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
int position = viewHolder.getAdapterPosition();
- mListModel.onTrigger(tabEnums.eModelCallback.M_CLEAR_BACKUP_WITHOUT_CLOSE,null);
boolean mStatus = onInitRemoveView(position, true);
if(mStatus){
mTabAdapter.onTrigger(tabEnums.eTabAdapterCommands.NOTIFY_SWIPE, Collections.singletonList(position));
@@ -167,6 +186,10 @@ public class tabController extends Fragment
}
/*View Handlers*/
+ public void onExitAndClearBackup(){
+ mListModel.onTrigger(tabEnums.eModelCallback.M_CLEAR_BACKUP_WITHOUT_CLOSE,null);
+ }
+
public void onRemoveTab(int pIndex){
mListModel.onTrigger(tabEnums.eModelCallback.M_REMOVE_TAB,Collections.singletonList(pIndex));
if(mListModel.getList().size()<1){
@@ -192,22 +215,26 @@ public class tabController extends Fragment
public void initTabCount()
{
mtabViewController.onTrigger(tabEnums.eTabViewCommands.INIT_TAB_COUNT, Collections.singletonList(mListModel.getList().size()));
- mHomeController.initTabCount();
+
+ ViewGroup.LayoutParams params = mRecycleView.getLayoutParams();
+ params.height = helperMethod.pxFromDp(mTabAdapter.getItemCount() * 90);
+ mRecycleView.setLayoutParams(params);
}
public void onClose(){
onClearTabBackup();
- // finish();
}
public void onNewTabInvoked(){
- mHomeController.onNewTabBackground(true,false);
+ mHomeController.onBackPressed();
+ int mBackupList = ((ArrayList)mListModel.onTrigger(tabEnums.eModelCallback.M_GET_BACKUP,null)).size();
+ if(mListModel.getList().size()-mBackupList>=1){
+ mHomeController.onNewTabBackground(true,false);
+ }
onClose();
- // overridePendingTransition(R.anim.popup_anim_in, R.anim.popup_anim_out);
}
public void onRestoreTab(View view){
- Log.i("FUCKSSS","FUCKSSS1 : " + (mPopupUndo.findViewById(R.id.pBlockerUndo).getVisibility()==View.VISIBLE));
mPopupUndo.findViewById(R.id.pBlockerUndo).setVisibility(View.VISIBLE);
mtabViewController.onTrigger(tabEnums.eTabViewCommands.ON_HIDE_UNDO_DIALOG, null);
@@ -220,7 +247,7 @@ public class tabController extends Fragment
ArrayList mBackup = (ArrayList)mListModel.onTrigger(tabEnums.eModelCallback.M_LOAD_BACKUP,null);
mTabAdapter.onTrigger(tabEnums.eTabAdapterCommands.REINIT_DATA, Collections.singletonList(mBackup));
- mListModel.onTrigger(tabEnums.eModelCallback.M_CLEAR_BACKUP_WITHOUT_CLOSE,null);
+ mListModel.onTrigger(tabEnums.eModelCallback.M_CLEAR_BACKUP_RETAIN_DATABASE,null);
initTabCount();
}
@@ -231,7 +258,7 @@ public class tabController extends Fragment
public void onClearTabBackup(){
ArrayList mBackupIndex = (ArrayList)mListModel.onTrigger(tabEnums.eModelCallback.M_GET_BACKUP,null);
for(int mCounter=0;mCounter= Build.VERSION_CODES.LOLLIPOP) {
+ Window window = mContext.getActivity().getWindow();
+ window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
+
+ if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) {
+ window.setStatusBarColor(mContext.getResources().getColor(R.color.blue_dark));
+ }
+ else {
+ if(AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_NO){
+ mContext.getActivity().getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
+ }
+ mContext.getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(mContext.getActivity(), R.color.c_background));
+ }
+ }
}
public void onOpenTabMenu(View view) {
@@ -159,12 +193,20 @@ class tabViewController
float width = height / 3;
if(pDX > 0){
- pCanvas.drawARGB(0, 241, 243, 244);
+ if(status.sTheme == enums.Theme.THEME_DARK){
+ pCanvas.drawARGB(255, 59, 57, 70);
+ }else {
+ pCanvas.drawARGB(255, 230, 230, 230);
+ }
icon = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.dustbin);
RectF icon_dest = new RectF((float) itemView.getLeft() + width ,(float) itemView.getTop() + width,(float) itemView.getLeft()+ 2*width,(float)itemView.getBottom() - width);
pCanvas.drawBitmap(icon,null,icon_dest, mPainter);
} else {
- pCanvas.drawARGB(0, 241, 243, 244);
+ if(status.sTheme == enums.Theme.THEME_DARK){
+ pCanvas.drawARGB(255, 59, 57, 70);
+ }else {
+ pCanvas.drawARGB(255, 230, 230, 230);
+ }
icon = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.dustbin);
RectF icon_dest = new RectF((float) itemView.getRight() - 2*width ,(float) itemView.getTop() + width,(float) itemView.getRight() - width,(float)itemView.getBottom() - width);
pCanvas.drawBitmap(icon,null,icon_dest, mPainter);
@@ -193,6 +235,8 @@ class tabViewController
onHideUndoDialog();
}else if(pCommands.equals(tabEnums.eTabViewCommands.ON_GENERATE_SWIPABLE_BACKGROUND)){
onDrawSwipableBackground((Canvas)pData.get(0), (RecyclerView.ViewHolder)pData.get(1), (float)pData.get(2), (int)pData.get(3));
+ }else if(pCommands.equals(tabEnums.eTabViewCommands.ON_EXIT)){
+ initExitUI();
}
return null;
}
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/constants/constants.java b/app/src/main/java/com/darkweb/genesissearchengine/constants/constants.java
index bc3dead3..d19cc3e1 100755
--- a/app/src/main/java/com/darkweb/genesissearchengine/constants/constants.java
+++ b/app/src/main/java/com/darkweb/genesissearchengine/constants/constants.java
@@ -20,13 +20,16 @@ public class constants
/*URL CONSTANTS*/
public static final String CONST_GENESIS_URL_CACHED = "resource://android/assets/homepage/homepage.html";
+ public static final String CONST_GENESIS_URL_CACHED_DARK = "resource://android/assets/homepage/homepage-dark.html";
public static final String CONST_GENESIS_ERROR_CACHED = "resource://android/assets/error/error.html";
+ public static final String CONST_GENESIS_ERROR_CACHED_DARK = "resource://android/assets/error/error-dark.html";
public static final String CONST_GENESIS_DOMAIN_URL_SLASHED = "https://boogle.store/";
public static final String CONST_GENESIS_REFERENCE_WEBSITES = "https://drive.google.com/uc?export=download&id=1lOmukKOPYHApBFyTDkaRPoAwm59E_YEE";
public static final String CONST_GENESIS_DOMAIN_URL = "https://boogle.store";
public static final String CONST_GENESIS_LOCAL_TIME_GET_KEY = "pLocalTimeVerificationToken";
public static final String CONST_GENESIS_GMT_TIME_GET_KEY = "pGlobalTimeVerificationToken";
public static final String CONST_GENESIS_HELP_URL_CACHE = "resource://android/assets/help/help.html";
+ public static final String CONST_GENESIS_HELP_URL_CACHE_DARK = "resource://android/assets/help/help-dark.html";
public static final String CONST_GENESIS_HELP_URL = "https://boogle.store/help";
public static final String CONST_GENESIS_HELP_URL_SUB = "boogle.store/help";
public static final String CONST_BACKEND_GENESIS_URL = "https://boogle.store/search?q=$s&p_num=1&s_type=all";
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/constants/status.java b/app/src/main/java/com/darkweb/genesissearchengine/constants/status.java
index 98c7ad06..1a811014 100755
--- a/app/src/main/java/com/darkweb/genesissearchengine/constants/status.java
+++ b/app/src/main/java/com/darkweb/genesissearchengine/constants/status.java
@@ -100,8 +100,8 @@ public class status
status.sCharacterEncoding = (boolean)dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_GET_BOOL, Arrays.asList(keys.SETTING_CHARACTER_ENCODING,false));
status.sShowImages = (int)dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_GET_INT, Arrays.asList(keys.SETTING_SHOW_IMAGES,0));
status.sShowWebFonts = (boolean)dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_GET_BOOL, Arrays.asList(keys.SETTING_SHOW_FONTS,true));
- status.sToolbarTheme = (boolean)dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_GET_BOOL, Arrays.asList(keys.SETTING_TOOLBAR_THEME,true));
status.sFullScreenBrowsing = (boolean)dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_GET_BOOL, Arrays.asList(keys.SETTING_FULL_SCREEN_BROWSIING,true));
+ status.sToolbarTheme = (boolean)dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_GET_BOOL, Arrays.asList(keys.SETTING_TOOLBAR_THEME,true));
status.sTheme = (int)dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_GET_INT, Arrays.asList(keys.SETTING_THEME,enums.Theme.THEME_DEFAULT));
status.sOpenURLInNewTab = (boolean)dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_GET_BOOL, Arrays.asList(keys.SETTING_OPEN_URL_IN_NEW_TAB,true));
status.sLogListView = (boolean)dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_GET_BOOL, Arrays.asList(keys.SETTING_LIST_VIEW,true));
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/dataManager/tabDataModel.java b/app/src/main/java/com/darkweb/genesissearchengine/dataManager/tabDataModel.java
index 941b3865..0ef5cfc6 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/dataManager/tabDataModel.java
+++ b/app/src/main/java/com/darkweb/genesissearchengine/dataManager/tabDataModel.java
@@ -58,7 +58,7 @@ class tabDataModel
mTabs.add(0,mTabModel);
if(mTabs.size()>20){
- closeTab(mTabs.get(mTabs.size()-1).getSession());
+ closeTab(mTabs.get(mTabs.size()-1).getSession(), mTabs.get(mTabs.size()-1).getmId());
}
if(pIsDataSavable){
@@ -89,14 +89,27 @@ class tabDataModel
}
- void closeTab(geckoSession mSession) {
- for(int counter = 0; counter< mTabs.size(); counter++){
- if(mTabs.get(counter).getSession().getSessionID().equals(mSession.getSessionID()))
- {
- databaseController.getInstance().execSQL("DELETE FROM tab WHERE mid='" + mTabs.get(counter).getmId() + "'",null);
- mTabs.remove(counter);
- break;
+ void closeTab(geckoSession mSession,Object pID) {
+ if(pID == null){
+ String mID = strings.GENERIC_EMPTY_STR;
+ for(int counter = 0; counter< mTabs.size(); counter++){
+ if(mTabs.get(counter).getSession().getSessionID().equals(mSession.getSessionID()))
+ {
+ mTabs.remove(counter);
+ mID = mTabs.get(counter).getmId();
+ break;
+ }
}
+ databaseController.getInstance().execSQL("DELETE FROM tab WHERE mid='" + mID + "'",null);
+ }else {
+ for(int counter = 0; counter< mTabs.size(); counter++){
+ if(mTabs.get(counter).getSession().getSessionID().equals(mSession.getSessionID()))
+ {
+ mTabs.remove(counter);
+ break;
+ }
+ }
+ databaseController.getInstance().execSQL("DELETE FROM tab WHERE mid='" + pID + "'",null);
}
}
@@ -189,7 +202,7 @@ class tabDataModel
};
// int isLoading = 0;
- public void updatePixels(String pSessionID, GeckoResult pBitmapManager, ImageView pImageView, NestedGeckoView pGeckoView){
+ public void updatePixels(String pSessionID, GeckoResult pBitmapManager, ImageView pImageView, NestedGeckoView pGeckoView, boolean pOpenTabView){
new Thread(){
public void run(){
@@ -217,7 +230,9 @@ class tabDataModel
} catch (Throwable throwable) {
throwable.printStackTrace();
}
- activityContextManager.getInstance().getHomeController().onOpenTabReady();
+ if(pOpenTabView){
+ activityContextManager.getInstance().getHomeController().onOpenTabReady();
+ }
}
}.start();
@@ -255,7 +270,7 @@ class tabDataModel
moveTabToTop((geckoSession)pData.get(0));
}
else if(pCommands == dataEnums.eTabCommands.CLOSE_TAB){
- closeTab((geckoSession)pData.get(0));
+ closeTab((geckoSession)pData.get(0), pData.get(1));
}
else if(pCommands == dataEnums.eTabCommands.M_CLEAR_TAB){
clearTab();
@@ -273,7 +288,7 @@ class tabDataModel
return getSuggestions((String) pData.get(0));
}
else if(pCommands == dataEnums.eTabCommands.M_UPDATE_PIXEL){
- updatePixels((String)pData.get(0), (GeckoResult)pData.get(1), (ImageView) pData.get(2), (NestedGeckoView) pData.get(3));
+ updatePixels((String)pData.get(0), (GeckoResult)pData.get(1), (ImageView) pData.get(2), (NestedGeckoView) pData.get(3), (Boolean) pData.get(4));
}
else if(pCommands == dataEnums.eTabCommands.M_HOME_PAGE){
return getHomePage();
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/helperManager/errorHandler.java b/app/src/main/java/com/darkweb/genesissearchengine/helperManager/errorHandler.java
index aa7f89e8..b4f5d39e 100755
--- a/app/src/main/java/com/darkweb/genesissearchengine/helperManager/errorHandler.java
+++ b/app/src/main/java/com/darkweb/genesissearchengine/helperManager/errorHandler.java
@@ -2,7 +2,12 @@ package com.darkweb.genesissearchengine.helperManager;
import androidx.appcompat.app.AppCompatActivity;
+import com.darkweb.genesissearchengine.constants.constants;
+import com.darkweb.genesissearchengine.constants.enums;
+import com.darkweb.genesissearchengine.constants.status;
import com.darkweb.genesissearchengine.constants.strings;
+import com.darkweb.genesissearchengine.dataManager.dataController;
+import com.darkweb.genesissearchengine.dataManager.dataEnums;
import com.example.myapplication.R;
import org.mozilla.geckoview.WebRequestError;
@@ -12,6 +17,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import static com.darkweb.genesissearchengine.constants.constants.CONST_GENESIS_ERROR_CACHED;
+import static com.darkweb.genesissearchengine.constants.constants.CONST_GENESIS_ERROR_CACHED_DARK;
+
public class errorHandler
{
private AppCompatActivity mContext;
@@ -23,7 +31,12 @@ public class errorHandler
BufferedReader reader = null;
StringBuilder builder = new StringBuilder();
try {
- stream = mContext.getResources().getAssets().open("error/error.html");
+ if(status.sTheme == enums.Theme.THEME_LIGHT || helperMethod.isDayMode(mContext)){
+ stream = mContext.getResources().getAssets().open(CONST_GENESIS_ERROR_CACHED);
+ }else {
+ stream = mContext.getResources().getAssets().open(CONST_GENESIS_ERROR_CACHED_DARK);
+ }
+
reader = new BufferedReader(new InputStreamReader(stream));
String line;
@@ -173,7 +186,11 @@ public class errorHandler
BufferedReader reader = null;
StringBuilder builder = new StringBuilder();
try {
- stream = mContext.getResources().getAssets().open("error/error.html");
+ if(status.sTheme == enums.Theme.THEME_LIGHT || helperMethod.isDayMode(mContext)){
+ stream = mContext.getResources().getAssets().open(CONST_GENESIS_ERROR_CACHED);
+ }else {
+ stream = mContext.getResources().getAssets().open(CONST_GENESIS_ERROR_CACHED_DARK);
+ }
reader = new BufferedReader(new InputStreamReader(stream));
String line;
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/helperManager/helperMethod.java b/app/src/main/java/com/darkweb/genesissearchengine/helperManager/helperMethod.java
index e664ac5d..7db5c2b1 100755
--- a/app/src/main/java/com/darkweb/genesissearchengine/helperManager/helperMethod.java
+++ b/app/src/main/java/com/darkweb/genesissearchengine/helperManager/helperMethod.java
@@ -66,6 +66,8 @@ import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import javax.crypto.Cipher;
import javax.net.ssl.HttpsURLConnection;
@@ -313,6 +315,10 @@ public class helperMethod
}
}
+ public static double getColorDensity(int pColor) {
+ return ColorUtils.calculateLuminance(pColor);
+ }
+
public static void shareApp(AppCompatActivity context, String p_share, String p_title) {
ShareCompat.IntentBuilder.from(context)
.setType("text/plain")
@@ -347,7 +353,7 @@ public class helperMethod
}
}
- static String getHost(String link){
+ static public String getHost(String link){
URL url;
try
{
@@ -408,6 +414,13 @@ public class helperMethod
return "Not Defined";
}
+ public static Boolean isValidURL(String url)
+ {
+ Pattern p = Pattern.compile("((http|https)://)(www.)?[a-zA-Z0-9@:%._\\+~#?&//=]{2,256}\\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%._\\+~#?&//=]*)");
+ Matcher m;
+ m=p.matcher(url);
+ return m.matches();
+ }
public static String capitalizeString(String string) {
char[] chars = string.toLowerCase().toCharArray();
@@ -492,6 +505,15 @@ public class helperMethod
pContext.startActivity(intent);
}
+ public static boolean isDayMode(AppCompatActivity pContext)
+ {
+ if(pContext.getResources().getString(R.string.mode).equals("Day")){
+ return true;
+ }else {
+ return false;
+ }
+ }
+
public static String getDomainName(String url)
{
try{
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/helperManager/localFileDownloader.java b/app/src/main/java/com/darkweb/genesissearchengine/helperManager/localFileDownloader.java
index f61d2f6b..53a2f89f 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/helperManager/localFileDownloader.java
+++ b/app/src/main/java/com/darkweb/genesissearchengine/helperManager/localFileDownloader.java
@@ -81,10 +81,11 @@ public class localFileDownloader extends AsyncTask {
.setChannelId(mID + "")
.setAutoCancel(false)
.setDefaults(0)
+ .setColor(Color.parseColor("#84989f"))
.setCategory(Notification.CATEGORY_SERVICE)
.setPriority(Notification.PRIORITY_DEFAULT)
.addAction(R.drawable.ic_download, "Cancel",pendingIntent)
- .setSmallIcon(R.drawable.ic_download);
+ .setSmallIcon(android.R.drawable.stat_sys_download);
build.setOngoing(Prefs.persistNotifications());
@@ -140,13 +141,21 @@ public class localFileDownloader extends AsyncTask {
}
+ build.setContentText("saving file");
+ build.setSmallIcon(android.R.drawable.stat_sys_download);
+ mNotifyManager.notify(mID, build.build());
+
output.flush();
output.close();
-
mStream.close();
} catch (Exception ex) {
- Log.i("ERROR", Objects.requireNonNull(ex.getMessage()));
+ build.setContentText("error occured while downloading file");
+ build.setAutoCancel(true);
+ build.setOngoing(false);
+ build.setPriority(Notification.PRIORITY_LOW);
+ build.setSmallIcon(android.R.drawable.stat_sys_download);
+ mNotifyManager.notify(mID, build.build());
}
return null;
@@ -172,11 +181,12 @@ public class localFileDownloader extends AsyncTask {
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, mID, snoozeIntentPost, PendingIntent.FLAG_UPDATE_CURRENT);
build.setContentIntent(pendingIntent);
- build.addAction(R.drawable.ic_download, "Open",pendingIntent);
+ build.addAction(android.R.drawable.stat_sys_download, "Open",pendingIntent);
build.setContentText("Download complete");
- build.setSmallIcon(R.drawable.ic_download_complete);
+ build.setSmallIcon(R.xml.ic_check);
build.setProgress(0, 0, false);
build.setAutoCancel(true);
+ build.setColor(Color.parseColor("#212d45"));
build.setOngoing(false);
build.setPriority(Notification.PRIORITY_LOW);
mNotifyManager.notify(mID, build.build());
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/adManager.java b/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/adManager.java
index b73c63f4..7963e58e 100755
--- a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/adManager.java
+++ b/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/adManager.java
@@ -35,17 +35,8 @@ class adManager
private void initializeBannerAds(){
if(!sPaidStatus){
AdRequest request = new AdRequest.Builder().build();
- new Timer().schedule(new TimerTask()
- {
- @Override
- public void run()
- {
- mAppContext.runOnUiThread(() -> {
- mBannerAds.loadAd(request);
- admobListeners();
- });
- }
- }, 1500);
+ mBannerAds.loadAd(request);
+ admobListeners();
}
}
diff --git a/app/src/main/res/custom-xml/generic/xml/gx_generic_input_create_bookmark.xml b/app/src/main/res/custom-xml/generic/xml/gx_generic_input_create_bookmark.xml
new file mode 100644
index 00000000..e533121d
--- /dev/null
+++ b/app/src/main/res/custom-xml/generic/xml/gx_generic_input_create_bookmark.xml
@@ -0,0 +1,23 @@
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/custom-xml/home/xml/hox_round_outline.xml b/app/src/main/res/custom-xml/home/xml/hox_round_outline.xml
index ddc69380..38e6c5c0 100644
--- a/app/src/main/res/custom-xml/home/xml/hox_round_outline.xml
+++ b/app/src/main/res/custom-xml/home/xml/hox_round_outline.xml
@@ -1,5 +1,5 @@
-
+
...
\ No newline at end of file
diff --git a/app/src/main/res/drawable-hdpi/genesis_vector.jpg b/app/src/main/res/drawable-hdpi/genesis_vector.jpg
new file mode 100644
index 00000000..9b3a17f4
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/genesis_vector.jpg differ
diff --git a/app/src/main/res/drawable/ic_genesis_vector.xml b/app/src/main/res/drawable/ic_genesis_vector.xml
new file mode 100644
index 00000000..916960fa
--- /dev/null
+++ b/app/src/main/res/drawable/ic_genesis_vector.xml
@@ -0,0 +1,1962 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layouts/alert/layout/popup_create_bookmark.xml b/app/src/main/res/layouts/alert/layout/popup_create_bookmark.xml
index a3f71b94..61486f62 100644
--- a/app/src/main/res/layouts/alert/layout/popup_create_bookmark.xml
+++ b/app/src/main/res/layouts/alert/layout/popup_create_bookmark.xml
@@ -62,7 +62,7 @@
android:layout_marginStart="10dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="10dp"
- android:background="@xml/gx_generic_input"
+ android:background="@xml/gx_generic_input_create_bookmark"
android:ems="10"
android:elevation="3dp"
android:hint="@string/ALERT_TITLE_ADD"
diff --git a/app/src/main/res/layouts/alert/layout/popup_download_full.xml b/app/src/main/res/layouts/alert/layout/popup_download_full.xml
index b08bb5d2..b86d40c6 100644
--- a/app/src/main/res/layouts/alert/layout/popup_download_full.xml
+++ b/app/src/main/res/layouts/alert/layout/popup_download_full.xml
@@ -38,25 +38,25 @@
android:id="@+id/pDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="5dp"
+ android:layout_marginTop="10dp"
android:alpha="0.6"
android:gravity="start"
android:paddingStart="15dp"
- android:lines="2"
android:paddingEnd="15dp"
- android:textDirection="locale"
+ android:text="@string/GENERAL_DEFAULT_TEXT"
android:textAlignment="viewStart"
- android:layout_marginEnd="30dp"
android:textColor="@color/c_alert_text"
- android:textSize="13sp"
+ android:textDirection="locale"
+ android:textSize="12sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/pHeader"
tools:ignore="SmallSp" />
+
+
+
+
+
diff --git a/app/src/main/res/layouts/alert/layout/popup_file_longpress.xml b/app/src/main/res/layouts/alert/layout/popup_file_longpress.xml
index a0f69cd3..43eb27a7 100644
--- a/app/src/main/res/layouts/alert/layout/popup_file_longpress.xml
+++ b/app/src/main/res/layouts/alert/layout/popup_file_longpress.xml
@@ -36,20 +36,17 @@
android:id="@+id/pDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="5dp"
- android:justificationMode="inter_word"
- android:paddingStart="15dp"
- android:textColor="@color/c_alert_text"
- android:ellipsize="start"
+ android:layout_marginTop="10dp"
android:alpha="0.6"
- android:lines="2"
+ android:ellipsize="start"
+ android:paddingStart="15dp"
android:paddingEnd="15dp"
- android:textDirection="locale"
+ android:text="@string/GENERAL_DEFAULT_TEXT"
android:textAlignment="viewStart"
- android:textSize="13sp"
+ android:textColor="@color/c_alert_text"
+ android:textDirection="locale"
+ android:textSize="12sp"
app:layout_constraintStart_toStartOf="parent"
- android:singleLine="true"
- android:layout_marginEnd="20dp"
app:layout_constraintTop_toBottomOf="@+id/pHeader"
tools:ignore="SmallSp" />
@@ -57,7 +54,7 @@
android:id="@+id/pDivider"
android:layout_width="match_parent"
android:layout_height="1dp"
- android:layout_marginTop="5dp"
+ android:layout_marginTop="20dp"
android:background="@color/c_view_divier_background"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
diff --git a/app/src/main/res/layouts/alert/layout/popup_report_url.xml b/app/src/main/res/layouts/alert/layout/popup_report_url.xml
index cdb107ed..9553833a 100644
--- a/app/src/main/res/layouts/alert/layout/popup_report_url.xml
+++ b/app/src/main/res/layouts/alert/layout/popup_report_url.xml
@@ -45,7 +45,7 @@
android:text="@string/ALERT_REPORT_URL_INFO"
android:textAlignment="textStart"
android:textColor="@color/c_alert_text"
- android:textSize="14sp"
+ android:textSize="13sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/pHeader"
diff --git a/app/src/main/res/layouts/alert/layout/popup_url_longpress.xml b/app/src/main/res/layouts/alert/layout/popup_url_longpress.xml
index d4316a4d..7406f5d3 100644
--- a/app/src/main/res/layouts/alert/layout/popup_url_longpress.xml
+++ b/app/src/main/res/layouts/alert/layout/popup_url_longpress.xml
@@ -35,18 +35,16 @@
android:id="@+id/pDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="5dp"
- android:justificationMode="inter_word"
+ android:layout_marginTop="10dp"
+ android:text="@string/GENERAL_DEFAULT_TEXT"
android:paddingStart="15dp"
android:textColor="@color/c_alert_text"
android:alpha="0.6"
- android:lines="2"
android:paddingEnd="15dp"
android:layout_marginEnd="20dp"
android:textDirection="locale"
android:textAlignment="viewStart"
- android:singleLine="true"
- android:textSize="13sp"
+ android:textSize="12sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/pHeader"
@@ -56,7 +54,7 @@
android:id="@+id/pDivider"
android:layout_width="match_parent"
android:layout_height="1dp"
- android:layout_marginTop="10dp"
+ android:layout_marginTop="20dp"
android:background="@color/c_view_divier_background"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
diff --git a/app/src/main/res/layouts/bridge/layout/bridge_settings_view.xml b/app/src/main/res/layouts/bridge/layout/bridge_settings_view.xml
index 98eb497e..8427e087 100644
--- a/app/src/main/res/layouts/bridge/layout/bridge_settings_view.xml
+++ b/app/src/main/res/layouts/bridge/layout/bridge_settings_view.xml
@@ -176,7 +176,7 @@
tools:ignore="RtlSymmetry">
diff --git a/app/src/main/res/layouts/home/layout/hint_view.xml b/app/src/main/res/layouts/home/layout/hint_view.xml
index ee684df3..53ad062d 100644
--- a/app/src/main/res/layouts/home/layout/hint_view.xml
+++ b/app/src/main/res/layouts/home/layout/hint_view.xml
@@ -49,6 +49,7 @@
android:background="@xml/hox_round_outline"
android:contentDescription="@string/GENERAL_TODO"
android:src="@xml/ic_baseline_browser"
+ app:tint="@color/c_text_v6"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/pHindTypeIcon"
app:layout_constraintTop_toTopOf="parent"
diff --git a/app/src/main/res/layouts/home/layout/home_view.xml b/app/src/main/res/layouts/home/layout/home_view.xml
index b6cd0fb3..fcba850a 100644
--- a/app/src/main/res/layouts/home/layout/home_view.xml
+++ b/app/src/main/res/layouts/home/layout/home_view.xml
@@ -709,6 +709,7 @@
android:layout_marginEnd="24dp"
android:layout_marginBottom="24dp"
android:alpha="0"
+ android:visibility="gone"
android:backgroundTint="@color/white"
android:clickable="true"
android:contentDescription="@string/GENERAL_TODO"
diff --git a/app/src/main/res/layouts/home/layout/popup_side_menu.xml b/app/src/main/res/layouts/home/layout/popup_side_menu.xml
index 2e4b8bc5..a9cdc3c5 100644
--- a/app/src/main/res/layouts/home/layout/popup_side_menu.xml
+++ b/app/src/main/res/layouts/home/layout/popup_side_menu.xml
@@ -148,7 +148,7 @@
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_marginEnd="15dp"
- android:background="@color/button_light" />
+ android:background="@color/c_home_side" />
+ android:background="@color/c_home_side" />
+ android:background="@color/c_home_side" />
#33cccc
#808080
#0c0b0e
- #ededed
+ #18171c
#24222a
#1c1b21
#3c3946
@@ -64,6 +64,7 @@
#f2f2f2
#00b300
#a6a6a6
+ #28282a
#ffffff
#242B64
@@ -109,6 +110,7 @@
#d9d9d9
#e3e3e3
#f2f2f2
+ #3b3946
#e6e6e6
#f8f8f8
#f2f2f2
diff --git a/app/src/main/res/values-night/strings.xml b/app/src/main/res/values-night/strings.xml
new file mode 100644
index 00000000..3427176a
--- /dev/null
+++ b/app/src/main/res/values-night/strings.xml
@@ -0,0 +1,6 @@
+
+
+
+ Night
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index c3a9a150..4f2223d9 100755
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -69,6 +69,7 @@
#f1f3f4
#00b300
#00b300
+ #e3e3e3
#05e6e6e6
#10e6e6e6
@@ -111,6 +112,7 @@
#d9d9d9
#e3e3e3
#f2f2f2
+ #f2f2f2
#e6e6e6
#f8f8f8
#f2f2f2
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index e8bcf554..39968e03 100755
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1,7 +1,9 @@
+ Day
Genesis
+ Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum
Search or type a web address
Find in page
Search Engine
@@ -201,7 +203,7 @@
Connection is secure
Your information(for example, password or credit card numbers) is private when it is sent to this site
Privacy Settings
- Download File
+ Download
Download
Report
Report Website
diff --git a/orbotOld/.gitignore b/orbotOld/.gitignore
deleted file mode 100644
index 796b96d1..00000000
--- a/orbotOld/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/build
diff --git a/orbotOld/build.gradle b/orbotOld/build.gradle
deleted file mode 100644
index 6c866eff..00000000
--- a/orbotOld/build.gradle
+++ /dev/null
@@ -1,68 +0,0 @@
-apply plugin: 'com.android.library'
-
-android {
- compileSdkVersion 30
- buildToolsVersion '30.0.3'
- ndkVersion '21.3.6528147'
-
- sourceSets {
- main {
- jniLibs.srcDirs = ['./src/main/libs']
- }
- }
-
- defaultConfig {
- minSdkVersion 16
- targetSdkVersion 30
- }
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
-
- aaptOptions {
- cruncherEnabled = false
- }
-
- lintOptions {
- checkReleaseBuilds false
- abortOnError true
-
- htmlReport true
- xmlReport false
- textReport false
-
- lintConfig file("../lint.xml")
- }
-
-}
-
-dependencies {
-
- implementation 'org.torproject:tor-android-binary:0.4.4.6'
-
- /**
- implementation 'info.pluggabletransports.aptds:apt-dispatch-library:1.0.9'
- implementation 'info.pluggabletransports.aptds:apt-meek-obfs4-legacy:1.0.9'
- **/
- implementation 'info.pluggabletransports.aptds:jsocksAndroid:1.0.4'
-
- implementation 'com.jaredrummler:android-shell:1.0.0'
- //implementation fileTree(dir: 'libs', include: ['.so','.aar'])
-
- implementation 'androidx.core:core:1.3.2'
- implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
- testImplementation 'junit:junit:4.13.1'
-
- implementation 'com.offbynull.portmapper:portmapper:2.0.5'
-
- implementation 'info.guardianproject:jtorctl:0.4'
-
- implementation 'com.github.tladesignz:IPtProxy:0.5.2'
-}
\ No newline at end of file
diff --git a/orbotOld/proguard-rules.pro b/orbotOld/proguard-rules.pro
deleted file mode 100644
index e69de29b..00000000
diff --git a/orbotOld/src/main/AndroidManifest.xml b/orbotOld/src/main/AndroidManifest.xml
deleted file mode 100644
index 589ee334..00000000
--- a/orbotOld/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
diff --git a/orbotOld/src/main/java/org/torproject/android/service/OrbotConstants.java b/orbotOld/src/main/java/org/torproject/android/service/OrbotConstants.java
deleted file mode 100644
index 3960fb6c..00000000
--- a/orbotOld/src/main/java/org/torproject/android/service/OrbotConstants.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Copyright (c) 2009, Nathan Freitas, Orbot/The Guardian Project - http://openideals.com/guardian */
-/* See LICENSE for licensing information */
-
-package org.torproject.android.service;
-
-public interface OrbotConstants {
-
- String TAG = "Orbot";
-
- String PREF_OR = "pref_or";
- String PREF_OR_PORT = "pref_or_port";
- String PREF_OR_NICKNAME = "pref_or_nickname";
- String PREF_REACHABLE_ADDRESSES = "pref_reachable_addresses";
- String PREF_REACHABLE_ADDRESSES_PORTS = "pref_reachable_addresses_ports";
-
- String PREF_DISABLE_NETWORK = "pref_disable_network";
-
- String PREF_TOR_SHARED_PREFS = "org.torproject.android_preferences";
-
- String PREF_SOCKS = "pref_socks";
-
- String PREF_HTTP = "pref_http";
-
- String PREF_ISOLATE_DEST = "pref_isolate_dest";
-
- String PREF_CONNECTION_PADDING = "pref_connection_padding";
- String PREF_REDUCED_CONNECTION_PADDING = "pref_reduced_connection_padding";
- String PREF_CIRCUIT_PADDING = "pref_circuit_padding";
- String PREF_REDUCED_CIRCUIT_PADDING = "pref_reduced_circuit_padding";
-
- String PREF_PREFER_IPV6 = "pref_prefer_ipv6";
- String PREF_DISABLE_IPV4 = "pref_disable_ipv4";
-
-
- String APP_TOR_KEY = "_app_tor";
- String APP_DATA_KEY = "_app_data";
- String APP_WIFI_KEY = "_app_wifi";
-}
diff --git a/orbotOld/src/main/java/org/torproject/android/service/OrbotService.java b/orbotOld/src/main/java/org/torproject/android/service/OrbotService.java
deleted file mode 100644
index 2c06e88f..00000000
--- a/orbotOld/src/main/java/org/torproject/android/service/OrbotService.java
+++ /dev/null
@@ -1,1867 +0,0 @@
-/* Copyright (c) 2009-2011, Nathan Freitas, Orbot / The Guardian Project - https://guardianproject.info/apps/orbot */
-/* See LICENSE for licensing information */
-/*
- * Code for iptables binary management taken from DroidWall GPLv3
- * Copyright (C) 2009-2010 Rodrigo Zechin Rosauro
- */
-
-package org.torproject.android.service;
-
-import android.annotation.SuppressLint;
-import android.app.Application;
-import android.app.Notification;
-import android.app.NotificationChannel;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
-import android.app.Service;
-import android.content.BroadcastReceiver;
-import android.content.ContentResolver;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.ContextWrapper;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.SharedPreferences;
-import android.content.pm.PackageManager;
-import android.database.Cursor;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-import android.net.Uri;
-import android.net.VpnService;
-import android.os.Build;
-import android.os.Handler;
-import android.os.IBinder;
-import android.provider.BaseColumns;
-import android.text.TextUtils;
-import android.util.Log;
-
-import androidx.annotation.RequiresApi;
-import androidx.core.app.NotificationCompat;
-import androidx.localbroadcastmanager.content.LocalBroadcastManager;
-
-import com.jaredrummler.android.shell.CommandResult;
-
-import net.freehaven.tor.control.TorControlCommands;
-import net.freehaven.tor.control.TorControlConnection;
-
-import org.torproject.android.service.util.CustomShell;
-import org.torproject.android.service.util.CustomTorResourceInstaller;
-import org.torproject.android.service.util.DummyActivity;
-import org.torproject.android.service.util.Prefs;
-import org.torproject.android.service.util.TorServiceUtils;
-import org.torproject.android.service.util.Utils;
-import org.torproject.android.service.vpn.OrbotVpnManager;
-import org.torproject.android.service.vpn.VpnPrefs;
-import org.torproject.android.service.wrapper.localHelperMethod;
-import org.torproject.android.service.wrapper.logRowModel;
-import org.torproject.android.service.wrapper.orbotLocalConstants;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.net.Socket;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Objects;
-import java.util.Random;
-import java.util.StringTokenizer;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeoutException;
-
-import IPtProxy.IPtProxy;
-
-public class OrbotService extends VpnService implements TorServiceConstants, OrbotConstants {
-
- public final static String BINARY_TOR_VERSION = org.torproject.android.binary.TorServiceConstants.BINARY_TOR_VERSION;
- static final int NOTIFY_ID = 1;
- private final static int CONTROL_SOCKET_TIMEOUT = 60000;
- private boolean mConnectivity = true;
- private static final int ERROR_NOTIFY_ID = 3;
- private static final int HS_NOTIFY_ID = 4;
- private Notification mNotification;
- private static final Uri V2_HS_CONTENT_URI = Uri.parse("content://org.torproject.android.ui.hiddenservices.providers/hs");
- private static final Uri V3_ONION_SERVICES_CONTENT_URI = Uri.parse("content://org.torproject.android.ui.v3onionservice/v3");
- private static final Uri COOKIE_CONTENT_URI = Uri.parse("content://org.torproject.android.ui.hiddenservices.providers.cookie/cookie");
- private static final Uri V3_CLIENT_AUTH_URI = Uri.parse("content://org.torproject.android.ui.v3onionservice.clientauth/v3auth");
- private final static String NOTIFICATION_CHANNEL_ID = "orbot_channel_1";
- private static final String[] LEGACY_V2_ONION_SERVICE_PROJECTION = new String[]{
- OnionService._ID,
- OnionService.NAME,
- OnionService.DOMAIN,
- OnionService.PORT,
- OnionService.AUTH_COOKIE,
- OnionService.AUTH_COOKIE_VALUE,
- OnionService.ONION_PORT,
- OnionService.ENABLED};
- private static final String[] V3_ONION_SERVICE_PROJECTION = new String[]{
- OnionService._ID,
- OnionService.NAME,
- OnionService.DOMAIN,
- OnionService.PORT,
- OnionService.ONION_PORT,
- OnionService.ENABLED,
- };
- private static final String[] LEGACY_COOKIE_PROJECTION = new String[]{
- ClientCookie._ID,
- ClientCookie.DOMAIN,
- ClientCookie.AUTH_COOKIE_VALUE,
- ClientCookie.ENABLED};
- private static final String[] V3_CLIENT_AUTH_PROJECTION = new String[]{
- V3ClientAuth._ID,
- V3ClientAuth.DOMAIN,
- V3ClientAuth.HASH,
- V3ClientAuth.ENABLED
- };
- public static int mPortSOCKS = -1;
- public static int mPortHTTP = -1;
- public static int mPortDns = TOR_DNS_PORT_DEFAULT;
- public static int mPortTrans = TOR_TRANSPROXY_PORT_DEFAULT;
- public static File appBinHome;
- public static File appCacheHome;
- public static File fileTor;
- public static File fileTorRc;
- private final ExecutorService mExecutor = Executors.newCachedThreadPool();
- boolean mIsLollipop = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
- TorEventHandler mEventHandler;
- OrbotVpnManager mVpnManager;
- Handler mHandler;
- //we should randomly sort alBridges so we don't have the same bridge order each time
- Random bridgeSelectRandom = new Random(System.nanoTime());
- ActionBroadcastReceiver mActionBroadcastReceiver;
- private String mCurrentStatus = STATUS_OFF;
- private TorControlConnection conn = null;
- private int mLastProcessId = -1;
- private File fileControlPort, filePid;
- private NotificationManager mNotificationManager = null;
- private NotificationCompat.Builder mNotifyBuilder;
- private boolean mNotificationShowing = false;
- private File mHSBasePath, mV3OnionBasePath, mV3AuthBasePath;
- private ArrayList alBridges = null;
-
- /**
- * @param bridgeList bridges that were manually entered into Orbot settings
- * @return Array with each bridge as an element, no whitespace entries see issue #289...
- */
- private static String[] parseBridgesFromSettings(String bridgeList) {
- // this regex replaces lines that only contain whitespace with an empty String
- bridgeList = bridgeList.trim().replaceAll("(?m)^[ \t]*\r?\n", "");
- return bridgeList.split("\\n");
- }
-
- private static boolean useIPtProxy() {
- String bridgeList = Prefs.getBridgesList();
- return bridgeList.contains("obfs3") || bridgeList.contains("obfs4") || bridgeList.contains("meek");
- }
-
- public void debug(String msg) {
- Log.d(OrbotConstants.TAG, msg);
-
- if (Prefs.useDebugLogging()) {
- sendCallbackLogMessage(msg);
- }
- }
-
- public void logException(String msg, Exception e) {
- if (Prefs.useDebugLogging()) {
- Log.e(OrbotConstants.TAG, msg, e);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- e.printStackTrace(new PrintStream(baos));
-
- sendCallbackLogMessage(msg + '\n' + new String(baos.toByteArray()));
-
- } else
- sendCallbackLogMessage(msg);
-
- }
-
- private void showConnectedToTorNetworkNotification() {
- showToolbarNotification(getString(R.string.status_activated), NOTIFY_ID, R.drawable.ic_stat_tor_logo);
- }
-
- private boolean findExistingTorDaemon() {
- try {
- mLastProcessId = initControlConnection(1, true);
-
- if (mLastProcessId != -1 && conn != null) {
- sendCallbackLogMessage(getString(R.string.found_existing_tor_process));
- sendCallbackStatus(STATUS_ON);
- showConnectedToTorNetworkNotification();
- return true;
- }
- } catch (Exception e) {
- debug("Error finding existing tor daemon: " + e);
- }
- return false;
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- logNotice("Low Memory Warning!");
- }
-
- private void clearNotifications() {
- if (mNotificationManager != null)
- mNotificationManager.cancelAll();
-
- if (mEventHandler != null)
- mEventHandler.getNodes().clear();
-
- mNotificationShowing = false;
- }
-
- @RequiresApi(api = Build.VERSION_CODES.O)
- private void createNotificationChannel() {
- NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
-
- CharSequence name = getString(R.string.app_name); // The user-visible name of the channel.
- String description = getString(R.string.app_description); // The user-visible description of the channel.
- NotificationChannel mChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, name, NotificationManager.IMPORTANCE_LOW);
- // Configure the notification channel.
- mChannel.setDescription(description);
- mChannel.enableLights(false);
- mChannel.enableVibration(false);
- mChannel.setShowBadge(false);
- mChannel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
- mNotificationManager.createNotificationChannel(mChannel);
- }
-
- @SuppressLint("NewApi")
- protected void showToolbarNotification(String notifyMsg, int notifyType, int icon) {
-
- if(orbotLocalConstants.mHomeContext ==null){
- return;
- }
-
- PackageManager pm = getPackageManager();
- Intent mIntent = orbotLocalConstants.mHomeIntent;
- mIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
- PendingIntent pendIntent = PendingIntent.getActivity(orbotLocalConstants.mHomeContext.get(), 0, mIntent, PendingIntent.FLAG_UPDATE_CURRENT);
-
- if (mNotifyBuilder == null) {
-
- mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
-
- if (mNotifyBuilder == null) {
- mNotifyBuilder = new NotificationCompat.Builder(this)
- .setContentTitle("Genesis")
- .setSmallIcon(R.drawable.ic_stat_tor_logo);
-
- mNotifyBuilder.setContentIntent(pendIntent);
-
- }
-
-
- mNotifyBuilder.setCategory(Notification.CATEGORY_SERVICE);
-
- mNotifyBuilder.setChannelId(NOTIFICATION_CHANNEL_ID);
-
-
- Intent intentRefresh = new Intent();
- intentRefresh.setAction(CMD_NEWNYM);
- PendingIntent pendingIntentNewNym = PendingIntent.getBroadcast(orbotLocalConstants.mHomeContext.get(), 0, intentRefresh, PendingIntent.FLAG_ONE_SHOT);
- mNotifyBuilder.addAction(R.drawable.ic_refresh_white_24dp, getString(R.string.menu_new_identity),
- pendingIntentNewNym);
-
- mNotifyBuilder.setOngoing(Prefs.persistNotifications());
-
- }
-
- mNotifyBuilder.setContentText(notifyMsg);
- mNotifyBuilder.setSmallIcon(icon);
-
- if (notifyType != NOTIFY_ID) {
- mNotifyBuilder.setTicker(notifyMsg);
- } else {
- mNotifyBuilder.setTicker(null);
- }
-
- if (!Prefs.persistNotifications())
- mNotifyBuilder.setPriority(Notification.PRIORITY_LOW);
-
- mNotification = mNotifyBuilder.build();
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- startForeground(NOTIFY_ID, mNotification);
- } else if (Prefs.persistNotifications() && (!mNotificationShowing)) {
- startForeground(NOTIFY_ID, mNotification);
- logNotice("Set background service to FOREGROUND");
- } else {
- mNotificationManager.notify(NOTIFY_ID, mNotification);
- }
-
- mNotificationShowing = true;
- }
-
- public int onStartCommand(Intent intent, int flags, int startId) {
- self = this;
- showToolbarNotification("", NOTIFY_ID, R.drawable.ic_stat_tor_logo);
-
- if (intent != null)
- exec(new IncomingIntentRouter(intent));
- else
- Log.d(OrbotConstants.TAG, "Got null onStartCommand() intent");
-
- return Service.START_STICKY;
- }
-
- public String getProxyStatus() {
- return mCurrentStatus;
- }
-
- @Override
- public void onTaskRemoved(Intent rootIntent) {
- Log.d(OrbotConstants.TAG, "task removed");
- Intent intent = new Intent(this, DummyActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- startActivity(intent);
- }
-
- @Override
- public void onDestroy() {
- try {
- unregisterReceiver(mNetworkStateReceiver);
- unregisterReceiver(mActionBroadcastReceiver);
- } catch (IllegalArgumentException iae) {
- //not registered yet
- }
-
- stopTorAsync();
-
- super.onDestroy();
- }
-
- private void stopTorAsync() {
-
- new Thread(() -> {
- Log.i("OrbotService", "stopTor");
- try {
- sendCallbackStatus(STATUS_STOPPING);
- sendCallbackLogMessage(getString(R.string.status_shutting_down));
-
- if (useIPtObfsMeekProxy())
- IPtProxy.stopObfs4Proxy();
-
- if (useIPtSnowflakeProxy())
- IPtProxy.stopSnowflake();
-
-
- stopTorDaemon(true);
-
- //stop the foreground priority and make sure to remove the persistant notification
- stopForeground(true);
-
- sendCallbackLogMessage(getString(R.string.status_disabled));
- } catch (Exception e) {
- logNotice("An error occured stopping Tor: " + e.getMessage());
- sendCallbackLogMessage(getString(R.string.something_bad_happened));
- }
- clearNotifications();
- sendCallbackStatus(STATUS_OFF);
- }).start();
- }
-
- private static boolean useIPtObfsMeekProxy() {
- String bridgeList = Prefs.getBridgesList();
- return bridgeList.contains("obfs") || bridgeList.contains("meek");
- }
-
- private static boolean useIPtSnowflakeProxy() {
- String bridgeList = Prefs.getBridgesList();
- return bridgeList.contains("snowflake");
- }
-
- private void startSnowflakeClient() {
- //this is using the current, default Tor snowflake infrastructure
- IPtProxy.startSnowflake("stun:stun.l.google.com:19302", "https://snowflake-broker.azureedge.net/",
- "ajax.aspnetcdn.com", null, true, false, true, 3);
- }
-
- /*
- This is to host a snowflake entrance node / bridge
- */
- private void runSnowflakeProxy () {
-
-
- // @param capacity Maximum concurrent clients. OPTIONAL. Defaults to 10, if 0.
-// @param broker Broker URL. OPTIONAL. Defaults to https://snowflake-broker.bamsoftware.com/, if empty.
-// @param relay WebSocket relay URL. OPTIONAL. Defaults to wss://snowflake.bamsoftware.com/, if empty.
-// @param stun STUN URL. OPTIONAL. Defaults to stun:stun.stunprotocol.org:3478, if empty.
-// @param logFile Name of log file. OPTIONAL
-// @param keepLocalAddresses Keep local LAN address ICE candidates.
-// @param unsafeLogging Prevent logs from being scrubbed.
-
- int capacity = 3;
- String broker = "https://snowflake-broker.bamsoftware.com/";
- String relay = "wss://snowflake.bamsoftware.com/";
- String stun = "stun:stun.stunprotocol.org:3478";
- String logFile = null;
- boolean keepLocalAddresses = true;
- boolean unsafeLogging = false;
- IPtProxy.startSnowflakeProxy(capacity, broker, relay, stun, logFile, keepLocalAddresses, unsafeLogging);
- }
- /**
- * if someone stops during startup, we may have to wait for the conn port to be setup, so we can properly shutdown tor
- */
- private void stopTorDaemon(boolean waitForConnection) throws Exception {
-
- int tryCount = 0;
-
- while (tryCount++ < 3) {
- if (conn != null) {
- logNotice("Using control port to shutdown Tor");
-
- try {
- logNotice("sending HALT signal to Tor process");
- conn.shutdownTor("SHUTDOWN");
-
- } catch (IOException e) {
- Log.d(OrbotConstants.TAG, "error shutting down Tor via connection", e);
- }
-
- conn = null;
- break;
- }
-
- if (!waitForConnection)
- break;
-
- try {
- Thread.sleep(3000);
- } catch (Exception e) {
- }
- }
- }
-
- private void requestTorRereadConfig() {
- try {
- if (conn != null)
- conn.signal("HUP");
-
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- protected void logNotice(String msg) {
- if (msg != null && msg.trim().length() > 0) {
- if (Prefs.useDebugLogging())
- Log.d(OrbotConstants.TAG, msg);
-
- sendCallbackLogMessage(msg);
- }
- }
-
- @Override
- public void onCreate() {
- super.onCreate();
-
- try {
- mHandler = new Handler();
-
- appBinHome = getFilesDir();//getDir(TorServiceConstants.DIRECTORY_TOR_BINARY, Application.MODE_PRIVATE);
- if (!appBinHome.exists())
- appBinHome.mkdirs();
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
- appCacheHome = new File(getDataDir(), DIRECTORY_TOR_DATA);
- } else {
- appCacheHome = getDir(DIRECTORY_TOR_DATA, Application.MODE_PRIVATE);
- }
-
- if (!appCacheHome.exists())
- appCacheHome.mkdirs();
-
- fileTorRc = new File(appBinHome, TORRC_ASSET_KEY);
- fileControlPort = new File(getFilesDir(), TOR_CONTROL_PORT_FILE);
- filePid = new File(getFilesDir(), TOR_PID_FILE);
-
- mHSBasePath = new File(getFilesDir().getAbsolutePath(), TorServiceConstants.HIDDEN_SERVICES_DIR);
- if (!mHSBasePath.isDirectory())
- mHSBasePath.mkdirs();
-
- mV3OnionBasePath = new File(getFilesDir().getAbsolutePath(), TorServiceConstants.ONION_SERVICES_DIR);
- if (!mV3OnionBasePath.isDirectory())
- mV3OnionBasePath.mkdirs();
-
- mV3AuthBasePath = new File(getFilesDir().getAbsolutePath(), TorServiceConstants.V3_CLIENT_AUTH_DIR);
- if (!mV3AuthBasePath.isDirectory())
- mV3AuthBasePath.mkdirs();
-
- mEventHandler = new TorEventHandler(this);
-
- if (mNotificationManager == null) {
- mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- }
-
- IntentFilter mNetworkStateFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
- registerReceiver(mNetworkStateReceiver , mNetworkStateFilter);
-
- IntentFilter filter = new IntentFilter();
- filter.addAction(CMD_NEWNYM);
- filter.addAction(CMD_ACTIVE);
- mActionBroadcastReceiver = new ActionBroadcastReceiver();
- registerReceiver(mActionBroadcastReceiver, filter);
-
- if (Build.VERSION.SDK_INT >= 26)
- createNotificationChannel();
-
- torUpgradeAndConfig();
-
- pluggableTransportInstall();
-
- new Thread(() -> {
- try {
- findExistingTorDaemon();
- } catch (Exception e) {
- Log.e(OrbotConstants.TAG, "error onBind", e);
- logNotice("error finding exiting process: " + e.toString());
- }
-
- }).start();
-
- mVpnManager = new OrbotVpnManager(this);
-
- } catch (Exception e) {
- //what error here
- Log.e(OrbotConstants.TAG, "Error installing Orbot binaries", e);
- logNotice("There was an error installing Orbot binaries");
- }
-
- Log.i("OrbotService", "onCreate end");
- }
-
- protected String getCurrentStatus() {
- return mCurrentStatus;
- }
-
- private boolean pluggableTransportInstall() {
-
- File fileCacheDir = new File(getCacheDir(), "pt");
- if (!fileCacheDir.exists())
- fileCacheDir.mkdir();
- IPtProxy.setStateLocation(fileCacheDir.getAbsolutePath());
- String fileTestState = IPtProxy.getStateLocation();
- debug("IPtProxy state: " + fileTestState);
-
- return false;
- }
-
- private boolean torUpgradeAndConfig() throws IOException, TimeoutException {
-
- SharedPreferences prefs = Prefs.getSharedPrefs(getApplicationContext());
- String version = prefs.getString(PREF_BINARY_TOR_VERSION_INSTALLED, null);
-
- logNotice("checking binary version: " + version);
-
- CustomTorResourceInstaller installer = new CustomTorResourceInstaller(this, appBinHome);
- logNotice("upgrading binaries to latest version: " + BINARY_TOR_VERSION);
-
- fileTor = installer.installResources();
-
- if (fileTor != null && fileTor.canExecute()) {
- prefs.edit().putString(PREF_BINARY_TOR_VERSION_INSTALLED, BINARY_TOR_VERSION).apply();
-
- fileTorRc = new File(appBinHome, "torrc");//installer.getTorrcFile();
- return fileTorRc.exists();
- }
-
- return false;
- }
-
- private File updateTorrcCustomFile() throws IOException, TimeoutException {
- SharedPreferences prefs = Prefs.getSharedPrefs(getApplicationContext());
-
- StringBuffer extraLines = new StringBuffer();
-
- extraLines.append("\n");
- extraLines.append("ControlPortWriteToFile").append(' ').append(fileControlPort.getCanonicalPath()).append('\n');
-
- extraLines.append("PidFile").append(' ').append(filePid.getCanonicalPath()).append('\n');
-
- extraLines.append("RunAsDaemon 0").append('\n');
- extraLines.append("AvoidDiskWrites 0").append('\n');
-
- String socksPortPref = prefs.getString(OrbotConstants.PREF_SOCKS, (TorServiceConstants.SOCKS_PROXY_PORT_DEFAULT));
-
- if (socksPortPref.indexOf(':') != -1)
- socksPortPref = socksPortPref.split(":")[1];
-
- socksPortPref = checkPortOrAuto(socksPortPref);
-
- String httpPortPref = prefs.getString(OrbotConstants.PREF_HTTP, (TorServiceConstants.HTTP_PROXY_PORT_DEFAULT));
-
- if (httpPortPref.indexOf(':') != -1)
- httpPortPref = httpPortPref.split(":")[1];
-
- httpPortPref = checkPortOrAuto(httpPortPref);
-
- String isolate = "";
- if (prefs.getBoolean(OrbotConstants.PREF_ISOLATE_DEST, false)) {
- isolate += " IsolateDestAddr ";
- }
-
- String ipv6Pref = "";
-
- if (prefs.getBoolean(OrbotConstants.PREF_PREFER_IPV6, true)) {
- ipv6Pref += " IPv6Traffic PreferIPv6 ";
- }
-
- if (prefs.getBoolean(OrbotConstants.PREF_DISABLE_IPV4, false)) {
- ipv6Pref += " IPv6Traffic NoIPv4Traffic ";
- }
-
- extraLines.append("SOCKSPort ").append(socksPortPref).append(isolate).append(ipv6Pref).append('\n');
- extraLines.append("SafeSocks 0").append('\n');
- extraLines.append("TestSocks 0").append('\n');
-
- if (Prefs.openProxyOnAllInterfaces())
- extraLines.append("SocksListenAddress 0.0.0.0").append('\n');
-
-
- extraLines.append("HTTPTunnelPort ").append(httpPortPref).append('\n');
-
- if (prefs.getBoolean(OrbotConstants.PREF_CONNECTION_PADDING, false)) {
- extraLines.append("ConnectionPadding 1").append('\n');
- }
-
- if (prefs.getBoolean(OrbotConstants.PREF_REDUCED_CONNECTION_PADDING, true)) {
- extraLines.append("ReducedConnectionPadding 1").append('\n');
- }
-
- if (prefs.getBoolean(OrbotConstants.PREF_CIRCUIT_PADDING, true)) {
- extraLines.append("CircuitPadding 1").append('\n');
- } else {
- extraLines.append("CircuitPadding 0").append('\n');
- }
-
- if (prefs.getBoolean(OrbotConstants.PREF_REDUCED_CIRCUIT_PADDING, true)) {
- extraLines.append("ReducedCircuitPadding 1").append('\n');
- }
-
- String transPort = prefs.getString("pref_transport", TorServiceConstants.TOR_TRANSPROXY_PORT_DEFAULT + "");
- String dnsPort = prefs.getString("pref_dnsport", TorServiceConstants.TOR_DNS_PORT_DEFAULT + "");
-
- extraLines.append("TransPort ").append(checkPortOrAuto(transPort)).append('\n');
- extraLines.append("DNSPort ").append(checkPortOrAuto(dnsPort)).append('\n');
-
- extraLines.append("VirtualAddrNetwork 10.192.0.0/10").append('\n');
- extraLines.append("AutomapHostsOnResolve 1").append('\n');
-
- extraLines.append("DormantClientTimeout 10 minutes").append('\n');
- // extraLines.append("DormantOnFirstStartup 0").append('\n');
- extraLines.append("DormantCanceledByStartup 1").append('\n');
-
- extraLines.append("DisableNetwork 0").append('\n');
-
- if (Prefs.useDebugLogging()) {
- extraLines.append("Log debug syslog").append('\n');
- extraLines.append("SafeLogging 0").append('\n');
- }
-
- extraLines = processSettingsImpl(extraLines);
-
- if (extraLines == null)
- return null;
-
- extraLines.append('\n');
- extraLines.append(prefs.getString("pref_custom_torrc", "")).append('\n');
-
- logNotice("updating torrc custom configuration...");
-
- debug("torrc.custom=" + extraLines.toString());
-
- File fileTorRcCustom = new File(fileTorRc.getAbsolutePath() + ".custom");
- boolean success = updateTorConfigCustom(fileTorRcCustom, extraLines.toString());
-
- if (success && fileTorRcCustom.exists()) {
- logNotice("success.");
- return fileTorRcCustom;
- } else
- return null;
-
- }
-
- private String checkPortOrAuto(String portString) {
- if (!portString.equalsIgnoreCase("auto")) {
- boolean isPortUsed = true;
- int port = Integer.parseInt(portString);
-
- while (isPortUsed) {
- isPortUsed = TorServiceUtils.isPortOpen("127.0.0.1", port, 500);
-
- if (isPortUsed) //the specified port is not available, so let Tor find one instead
- port++;
- }
- return port + "";
- }
-
- return portString;
- }
-
- public boolean updateTorConfigCustom(File fileTorRcCustom, String extraLines) throws IOException, TimeoutException {
- FileWriter fos = new FileWriter(fileTorRcCustom, false);
- PrintWriter ps = new PrintWriter(fos);
- ps.print(extraLines);
- ps.flush();
- ps.close();
- return true;
- }
-
- /**
- * Send Orbot's status in reply to an
- * {@link TorServiceConstants#ACTION_START} {@link Intent}, targeted only to
- * the app that sent the initial request. If the user has disabled auto-
- * starts, the reply {@code ACTION_START Intent} will include the extra
- * {@link TorServiceConstants#STATUS_STARTS_DISABLED}
- */
- private void replyWithStatus(Intent startRequest) {
- String packageName = startRequest.getStringExtra(EXTRA_PACKAGE_NAME);
-
- Intent reply = new Intent(ACTION_STATUS);
- reply.putExtra(EXTRA_STATUS, mCurrentStatus);
- reply.putExtra(EXTRA_SOCKS_PROXY, "socks://127.0.0.1:" + mPortSOCKS);
- reply.putExtra(EXTRA_SOCKS_PROXY_HOST, "127.0.0.1");
- reply.putExtra(EXTRA_SOCKS_PROXY_PORT, mPortSOCKS);
- reply.putExtra(EXTRA_HTTP_PROXY, "http://127.0.0.1:" + mPortHTTP);
- reply.putExtra(EXTRA_HTTP_PROXY_HOST, "127.0.0.1");
- reply.putExtra(EXTRA_HTTP_PROXY_PORT, mPortHTTP);
-
- if (packageName != null) {
- reply.setPackage(packageName);
- sendBroadcast(reply);
- }
-
- LocalBroadcastManager.getInstance(this).sendBroadcast(reply);
-
- if (mPortSOCKS != -1 && mPortHTTP != -1)
- sendCallbackPorts(mPortSOCKS, mPortHTTP, mPortDns, mPortTrans);
-
- }
-
- /**
- * The entire process for starting tor and related services is run from this method.
- */
- private void startTor() {
- try {
-
- // STATUS_STARTING is set in onCreate()
- if (mCurrentStatus.equals(STATUS_STOPPING)) {
- // these states should probably be handled better
- sendCallbackLogMessage("Ignoring start request, currently " + mCurrentStatus);
- return;
- } else if (mCurrentStatus.equals(STATUS_ON) && (mLastProcessId != -1)) {
- showConnectedToTorNetworkNotification();
- sendCallbackLogMessage("Ignoring start request, already started.");
- // setTorNetworkEnabled (true);
-
- return;
- }
-
- sendCallbackStatus(STATUS_STARTING);
-
- try {
- if (conn != null) {
- String torProcId = conn.getInfo("process/pid");
- if (!TextUtils.isEmpty(torProcId))
- mLastProcessId = Integer.parseInt(torProcId);
- } else {
- if (fileControlPort != null && fileControlPort.exists())
- findExistingTorDaemon();
-
- }
- } catch (Exception e) {
- }
-
- // make sure there are no stray daemons running
- stopTorDaemon(false);
-
- SharedPreferences prefs = Prefs.getSharedPrefs(getApplicationContext());
- String version = prefs.getString(PREF_BINARY_TOR_VERSION_INSTALLED, null);
- logNotice("checking binary version: " + version);
-
- showToolbarNotification(getString(R.string.status_starting_up), NOTIFY_ID, R.drawable.ic_stat_tor_logo);
- //sendCallbackLogMessage(getString(R.string.status_starting_up));
- //logNotice(getString(R.string.status_starting_up));
-
- ArrayList customEnv = new ArrayList<>();
-
- if (Prefs.bridgesEnabled())
- if (Prefs.useVpn() && !mIsLollipop) {
- customEnv.add("TOR_PT_PROXY=socks5://" + OrbotVpnManager.sSocksProxyLocalhost + ":" + OrbotVpnManager.sSocksProxyServerPort);
- }
-
- boolean success = runTorShellCmd();
-
- if (success) {
- try {
- updateLegacyV2OnionNames();
- } catch (SecurityException se) {
- logNotice("unable to upload legacy v2 onion names");
- }
- try {
- updateV3OnionNames();
- } catch (SecurityException se) {
- logNotice("unable to upload v3 onion names");
- }
- }
-
- } catch (Exception e) {
- logException("Unable to start Tor: " + e.toString(), e);
- stopTorAsync();
- showToolbarNotification(
- getString(R.string.unable_to_start_tor) + ": " + e.getMessage(),
- ERROR_NOTIFY_ID, R.drawable.ic_stat_notifyerr);
- }
- }
-
-
- private void updateV3OnionNames() throws SecurityException {
- ContentResolver contentResolver = getApplicationContext().getContentResolver();
- Cursor onionServices = contentResolver.query(V3_ONION_SERVICES_CONTENT_URI, null, null, null, null);
- if (onionServices != null) {
- try {
- while (onionServices.moveToNext()) {
- String domain = onionServices.getString(onionServices.getColumnIndex(OnionService.DOMAIN));
- int localPort = onionServices.getInt(onionServices.getColumnIndex(OnionService.PORT));
-
- if (domain == null || TextUtils.isEmpty(domain)) {
- String v3OnionDirPath = new File(mV3OnionBasePath.getAbsolutePath(), "v3" + localPort).getCanonicalPath();
- File hostname = new File(v3OnionDirPath, "hostname");
- if (hostname.exists()) {
- domain = Utils.readString(new FileInputStream(hostname)).trim();
- ContentValues fields = new ContentValues();
- fields.put(OnionService.DOMAIN, domain);
- contentResolver.update(V3_ONION_SERVICES_CONTENT_URI, fields, "port=" + localPort, null);
- }
- }
-
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- onionServices.close();
- }
- }
-
- private void updateLegacyV2OnionNames() throws SecurityException {
- // Tor is running, update new .onion names at db
- ContentResolver mCR = getApplicationContext().getContentResolver();
- Cursor hidden_services = mCR.query(V2_HS_CONTENT_URI, LEGACY_V2_ONION_SERVICE_PROJECTION, null, null, null);
- if (hidden_services != null) {
- try {
- while (hidden_services.moveToNext()) {
- String HSDomain = hidden_services.getString(hidden_services.getColumnIndex(OnionService.DOMAIN));
- Integer HSLocalPort = hidden_services.getInt(hidden_services.getColumnIndex(OnionService.PORT));
- Integer HSAuthCookie = hidden_services.getInt(hidden_services.getColumnIndex(OnionService.AUTH_COOKIE));
- String HSAuthCookieValue = hidden_services.getString(hidden_services.getColumnIndex(OnionService.AUTH_COOKIE_VALUE));
-
- // Update only new domains or restored from backup with auth cookie
- if ((HSDomain == null || HSDomain.length() < 1) || (HSAuthCookie == 1 && (HSAuthCookieValue == null || HSAuthCookieValue.length() < 1))) {
- String hsDirPath = new File(mHSBasePath.getAbsolutePath(), "hs" + HSLocalPort).getCanonicalPath();
- File file = new File(hsDirPath, "hostname");
-
- if (file.exists()) {
- ContentValues fields = new ContentValues();
-
- try {
- String onionHostname = Utils.readString(new FileInputStream(file)).trim();
- if (HSAuthCookie == 1) {
- String[] aux = onionHostname.split(" ");
- onionHostname = aux[0];
- fields.put(OnionService.AUTH_COOKIE_VALUE, aux[1]);
- }
- fields.put(OnionService.DOMAIN, onionHostname);
- mCR.update(V2_HS_CONTENT_URI, fields, "port=" + HSLocalPort, null);
- } catch (FileNotFoundException e) {
- logException("unable to read onion hostname file", e);
- showToolbarNotification(getString(R.string.unable_to_read_hidden_service_name), HS_NOTIFY_ID, R.drawable.ic_stat_notifyerr);
- }
- } else {
- showToolbarNotification(getString(R.string.unable_to_read_hidden_service_name), HS_NOTIFY_ID, R.drawable.ic_stat_notifyerr);
-
- }
- }
- }
-
- } catch (NumberFormatException e) {
- Log.e(OrbotConstants.TAG, "error parsing hsport", e);
- } catch (Exception e) {
- Log.e(OrbotConstants.TAG, "error starting share server", e);
- }
-
- hidden_services.close();
- }
- }
-
- private boolean runTorShellCmd() throws Exception {
- File fileTorrcCustom = updateTorrcCustomFile();
-
- //make sure Tor exists and we can execute it
- if (fileTor == null || (!fileTor.exists()) || (!fileTor.canExecute()))
- return false;
-
- if ((!fileTorRc.exists()) || (!fileTorRc.canRead()))
- return false;
-
- if ((!fileTorrcCustom.exists()) || (!fileTorrcCustom.canRead()))
- return false;
-
- sendCallbackLogMessage(getString(R.string.status_starting_up));
-
- String torCmdString = fileTor.getAbsolutePath()
- + " DataDirectory " + appCacheHome.getAbsolutePath()
- + " --defaults-torrc " + fileTorRc.getAbsolutePath()
- + " -f " + fileTorrcCustom.getAbsolutePath();
-
- int exitCode = -1;
-
- try {
- exitCode = exec(torCmdString + " --verify-config", true);
- } catch (Exception e) {
- logNotice("Tor configuration did not verify: " + e.getMessage());
- return false;
- }
-
- if (exitCode == 0) {
- logNotice("Tor configuration VERIFIED.");
- try {
- exitCode = exec(torCmdString, false);
- } catch (Exception e) {
- logNotice("Tor was unable to start: " + e.getMessage());
- throw new Exception("Tor was unable to start: " + e.getMessage());
- }
-
- if (exitCode != 0) {
- logNotice("Tor did not start. Exit:" + exitCode);
- return false;
- }
-
- //now try to connect
- mLastProcessId = initControlConnection(10, false);
-
- if (mLastProcessId == -1) {
- logNotice(getString(R.string.couldn_t_start_tor_process_) + "; exit=" + exitCode);
- throw new Exception(getString(R.string.couldn_t_start_tor_process_) + "; exit=" + exitCode);
- } else {
- logNotice("Tor started; process id=" + mLastProcessId);
- }
- }
-
- return true;
- }
-
- protected void exec(Runnable runn) {
- mExecutor.execute(runn);
- }
-
- private int exec(String cmd, boolean wait) throws Exception {
- HashMap mapEnv = new HashMap<>();
- mapEnv.put("HOME", appBinHome.getAbsolutePath());
-
- CommandResult result = CustomShell.run("sh", wait, mapEnv, cmd);
- debug("executing: " + cmd);
- debug("stdout: " + result.getStdout());
- debug("stderr: " + result.getStderr());
-
- return result.exitCode;
- }
-
- private int initControlConnection(int maxTries, boolean isReconnect) throws Exception {
- int controlPort = -1;
- int attempt = 0;
-
- logNotice(getString(R.string.waiting_for_control_port));
-
- while (conn == null && attempt++ < maxTries && (!mCurrentStatus.equals(STATUS_OFF))) {
- try {
- controlPort = getControlPort();
- if (controlPort != -1) {
- logNotice(getString(R.string.connecting_to_control_port) + controlPort);
- break;
- }
-
- } catch (Exception ce) {
- conn = null;
- // logException( "Error connecting to Tor local control port: " + ce.getMessage(),ce);
- }
-
- try {
- // logNotice("waiting...");
- Thread.sleep(2000);
- } catch (Exception e) {
- }
- }
-
- if (controlPort != -1) {
- Socket torConnSocket = new Socket(IP_LOCALHOST, controlPort);
- torConnSocket.setSoTimeout(CONTROL_SOCKET_TIMEOUT);
- conn = new TorControlConnection(torConnSocket);
- conn.launchThread(true);//is daemon
- }
-
- if (conn != null) {
- logNotice("SUCCESS connected to Tor control port.");
-
- File fileCookie = new File(appCacheHome, TOR_CONTROL_COOKIE);
-
- if (fileCookie.exists()) {
- logNotice("adding control port event handler");
-
- conn.setEventHandler(mEventHandler);
-
- logNotice("SUCCESS added control port event handler");
- byte[] cookie = new byte[(int) fileCookie.length()];
- DataInputStream fis = new DataInputStream(new FileInputStream(fileCookie));
- fis.read(cookie);
- fis.close();
- conn.authenticate(cookie);
-
- logNotice("SUCCESS - authenticated to control port.");
-
- // conn.setEvents(Arrays.asList(new String[]{"DEBUG","STATUS_CLIENT","STATUS_GENERAL","BW"}));
-
- if (Prefs.useDebugLogging())
- conn.setEvents(Arrays.asList("CIRC", "STREAM", "ORCONN", "BW", "INFO", "NOTICE", "WARN", "DEBUG", "ERR", "NEWDESC", "ADDRMAP"));
- else
- conn.setEvents(Arrays.asList("CIRC", "STREAM", "ORCONN", "BW", "NOTICE", "ERR", "NEWDESC", "ADDRMAP"));
-
- // sendCallbackLogMessage(getString(R.string.tor_process_starting) + ' ' + getString(R.string.tor_process_complete));
-
- String torProcId = conn.getInfo("process/pid");
-
- String confSocks = conn.getInfo("net/listeners/socks");
- StringTokenizer st = new StringTokenizer(confSocks, " ");
-
- confSocks = st.nextToken().split(":")[1];
- confSocks = confSocks.substring(0, confSocks.length() - 1);
- mPortSOCKS = Integer.parseInt(confSocks);
-
- String confHttp = conn.getInfo("net/listeners/httptunnel");
- st = new StringTokenizer(confHttp, " ");
-
- confHttp = st.nextToken().split(":")[1];
- confHttp = confHttp.substring(0, confHttp.length() - 1);
- mPortHTTP = Integer.parseInt(confHttp);
-
- String confDns = conn.getInfo("net/listeners/dns");
- st = new StringTokenizer(confDns, " ");
- if (st.hasMoreTokens()) {
- confDns = st.nextToken().split(":")[1];
- confDns = confDns.substring(0, confDns.length() - 1);
- mPortDns = Integer.parseInt(confDns);
- Prefs.getSharedPrefs(getApplicationContext()).edit().putInt(VpnPrefs.PREFS_DNS_PORT, mPortDns).apply();
- }
-
- String confTrans = conn.getInfo("net/listeners/trans");
- st = new StringTokenizer(confTrans, " ");
- if (st.hasMoreTokens()) {
- confTrans = st.nextToken().split(":")[1];
- confTrans = confTrans.substring(0, confTrans.length() - 1);
- mPortTrans = Integer.parseInt(confTrans);
- }
-
- sendCallbackPorts(mPortSOCKS, mPortHTTP, mPortDns, mPortTrans);
- setTorNetworkEnabled(true);
-
- return Integer.parseInt(torProcId);
-
- } else {
- logNotice("Tor authentication cookie does not exist yet");
- conn = null;
-
- }
- }
-
- throw new Exception("Tor control port could not be found");
- }
-
- private int getControlPort() {
- int result = -1;
-
- try {
- if (fileControlPort.exists()) {
- debug("Reading control port config file: " + fileControlPort.getCanonicalPath());
- BufferedReader bufferedReader = new BufferedReader(new FileReader(fileControlPort));
- String line = bufferedReader.readLine();
-
- if (line != null) {
- String[] lineParts = line.split(":");
- result = Integer.parseInt(lineParts[1]);
- }
-
-
- bufferedReader.close();
-
- //store last valid control port
- SharedPreferences prefs = Prefs.getSharedPrefs(getApplicationContext());
- prefs.edit().putInt("controlport", result).apply();
- } else {
- debug("Control Port config file does not yet exist (waiting for tor): " + fileControlPort.getCanonicalPath());
- }
- } catch (FileNotFoundException e) {
- debug("unable to get control port; file not found");
- } catch (Exception e) {
- debug("unable to read control port config file");
- }
-
- return result;
- }
-
- public String getInfo(String key) {
- try {
- if (conn != null) {
- return conn.getInfo(key);
- }
- } catch (Exception ioe) {
- // Log.e(TAG,"Unable to get Tor information",ioe);
- logNotice("Unable to get Tor information" + ioe.getMessage());
- }
- return null;
- }
-
- public void setTorNetworkEnabled(final boolean isEnabled) throws IOException {
- if (conn != null) { // it is possible to not have a connection yet, and someone might try to newnym
- new Thread() {
- public void run() {
- try {
- final String newValue = isEnabled ? "0" : "1";
- conn.setConf("DisableNetwork", newValue);
- } catch (Exception ioe) {
- debug("error requesting newnym: " + ioe.getLocalizedMessage());
- }
- }
- }.start();
- }
- }
-
- public void sendSignalActive() {
- if (conn != null && mCurrentStatus == STATUS_ON) {
- try {
- conn.signal("ACTIVE");
- } catch (IOException e) {
- debug("error send active: " + e.getLocalizedMessage());
- }
- }
- }
-
- public void newIdentity() {
- if (conn != null) { // it is possible to not have a connection yet, and someone might try to newnym
- new Thread() {
- public void run() {
- try {
- int iconId = R.drawable.ic_stat_tor_logo;
-
- if (conn != null) {
- if (mCurrentStatus.equals(STATUS_ON) && Prefs.expandedNotifications())
- showToolbarNotification(getString(R.string.newnym), NOTIFY_ID, iconId);
-
- conn.signal(TorControlCommands.SIGNAL_NEWNYM);
- }
-
- } catch (Exception ioe) {
- debug("error requesting newnym: " + ioe.getLocalizedMessage());
- }
- }
- }.start();
- }
- }
-
- protected void sendCallbackBandwidth(long upload, long download, long written, long read) {
- Intent intent = new Intent(LOCAL_ACTION_BANDWIDTH);
-
- intent.putExtra("up", upload);
- intent.putExtra("down", download);
- intent.putExtra("written", written);
- intent.putExtra("read", read);
- intent.putExtra(EXTRA_STATUS, mCurrentStatus);
-
- LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
- }
-
- private void sendCallbackLogMessage(String logMessage)
- {
-
- mHandler.post(() -> {
- Intent intent = new Intent(LOCAL_ACTION_LOG);
- intent.putExtra(LOCAL_EXTRA_LOG, logMessage);
- intent.putExtra(EXTRA_STATUS, mCurrentStatus);
- orbotLocalConstants.mTorLogsHistory.add(new logRowModel(logMessage, localHelperMethod.getCurrentTime()));
-
- if(!mConnectivity){
- orbotLocalConstants.mTorLogsStatus = "No internet connection";
- }else {
- orbotLocalConstants.mTorLogsStatus = logMessage;
- }
- LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
- });
-
- }
-
- private void sendCallbackPorts(int socksPort, int httpPort, int dnsPort, int transPort) {
- Intent intent = new Intent(LOCAL_ACTION_PORTS); // You can also include some extra data.
- intent.putExtra(EXTRA_SOCKS_PROXY_PORT, socksPort);
- intent.putExtra(EXTRA_HTTP_PROXY_PORT, httpPort);
- intent.putExtra(EXTRA_DNS_PORT, dnsPort);
- intent.putExtra(EXTRA_TRANS_PORT, transPort);
-
- LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
-
- if (Prefs.useVpn())
- mVpnManager.handleIntent(new Builder(), intent);
-
- }
-
- protected void sendCallbackStatus(String currentStatus) {
-
- //Log.i("MFUCKER","MFUCKER : " + currentStatus);
- if(currentStatus.equals("ON")){
- orbotLocalConstants.mIsTorInitialized = true;
- }
- //Log.i("FUCKSS","FUCKSS:"+currentStatus);
- mCurrentStatus = currentStatus;
- Intent intent = getActionStatusIntent(currentStatus);
- // send for Orbot internals, using secure local broadcast
- sendBroadcastOnlyToOrbot(intent);
- // send for any apps that are interested
- sendBroadcast(intent);
- }
-
- /**
- * Send a secure broadcast only to Orbot itself
- *
- * @see {@link ContextWrapper#sendBroadcast(Intent)}
- * @see {@link LocalBroadcastManager}
- */
- private boolean sendBroadcastOnlyToOrbot(Intent intent) {
- return LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
- }
-
- private Intent getActionStatusIntent(String currentStatus) {
- Intent intent = new Intent(ACTION_STATUS);
- intent.putExtra(EXTRA_STATUS, currentStatus);
- return intent;
- }
-
- private StringBuffer processSettingsImpl(StringBuffer extraLines) throws IOException {
- logNotice(getString(R.string.updating_settings_in_tor_service));
- SharedPreferences prefs = Prefs.getSharedPrefs(getApplicationContext());
-
- boolean useBridges = Prefs.bridgesEnabled();
- boolean becomeRelay = prefs.getBoolean(OrbotConstants.PREF_OR, false);
- boolean ReachableAddresses = prefs.getBoolean(OrbotConstants.PREF_REACHABLE_ADDRESSES, false);
- boolean enableStrictNodes = prefs.getBoolean("pref_strict_nodes", false);
- String entranceNodes = prefs.getString("pref_entrance_nodes", "");
- String exitNodes = prefs.getString("pref_exit_nodes", "");
- String excludeNodes = prefs.getString("pref_exclude_nodes", "");
-
- if (!useBridges) {
- extraLines.append("UseBridges 0").append('\n');
- if (Prefs.useVpn()) { //set the proxy here if we aren't using a bridge
- if (!mIsLollipop) {
- String proxyType = "socks5";
- extraLines.append(proxyType + "Proxy" + ' ' + OrbotVpnManager.sSocksProxyLocalhost + ':' + OrbotVpnManager.sSocksProxyServerPort).append('\n');
- }
-
- } else {
- String proxyType = prefs.getString("pref_proxy_type", null);
- if (proxyType != null && proxyType.length() > 0) {
- String proxyHost = prefs.getString("pref_proxy_host", null);
- String proxyPort = prefs.getString("pref_proxy_port", null);
- String proxyUser = prefs.getString("pref_proxy_username", null);
- String proxyPass = prefs.getString("pref_proxy_password", null);
-
- if ((proxyHost != null && proxyHost.length() > 0) && (proxyPort != null && proxyPort.length() > 0)) {
- extraLines.append(proxyType).append("Proxy").append(' ').append(proxyHost).append(':').append(proxyPort).append('\n');
-
- if (proxyUser != null && proxyPass != null) {
- if (proxyType.equalsIgnoreCase("socks5")) {
- extraLines.append("Socks5ProxyUsername").append(' ').append(proxyUser).append('\n');
- extraLines.append("Socks5ProxyPassword").append(' ').append(proxyPass).append('\n');
- } else
- extraLines.append(proxyType).append("ProxyAuthenticator").append(' ').append(proxyUser).append(':').append(proxyPort).append('\n');
-
- } else if (proxyPass != null)
- extraLines.append(proxyType).append("ProxyAuthenticator").append(' ').append(proxyUser).append(':').append(proxyPort).append('\n');
- }
- }
- }
- } else {
-
- loadBridgeDefaults();
- extraLines.append("UseBridges 1").append('\n');
- // extraLines.append("UpdateBridgesFromAuthority 1").append('\n');
-
- String bridgeList = Prefs.getBridgesList();
-
- String builtInBridgeType = null;
-
- //check if any PT bridges are needed
- if (bridgeList.contains("obfs")) {
- extraLines.append("ClientTransportPlugin obfs3 socks5 127.0.0.1:" + IPtProxy.Obfs3SocksPort).append('\n');
- extraLines.append("ClientTransportPlugin obfs4 socks5 127.0.0.1:" + IPtProxy.Obfs4SocksPort).append('\n');
-
- if (bridgeList.equals("obfs4"))
- builtInBridgeType = "obfs4";
- }
-
- if (bridgeList.equals("meek")) {
- extraLines.append("ClientTransportPlugin meek_lite socks5 127.0.0.1:" + IPtProxy.MeekSocksPort).append('\n');
- builtInBridgeType = "meek_lite";
- }
-
- if (bridgeList.equals("snowflake")) {
- extraLines.append("ClientTransportPlugin snowflake socks5 127.0.0.1:" + IPtProxy.SnowflakeSocksPort).append('\n');
- builtInBridgeType = "snowflake";
- }
-
- if (!TextUtils.isEmpty(builtInBridgeType))
- getBridges(builtInBridgeType, extraLines);
- else {
- String[] bridgeListLines = parseBridgesFromSettings(bridgeList);
- int bridgeIdx = (int) Math.floor(Math.random() * ((double) bridgeListLines.length));
- String bridgeLine = bridgeListLines[bridgeIdx];
- extraLines.append("Bridge ");
- extraLines.append(bridgeLine);
- extraLines.append("\n");
- }
- }
-
- //only apply GeoIP if you need it
- File fileGeoIP = new File(appBinHome, GEOIP_ASSET_KEY);
- File fileGeoIP6 = new File(appBinHome, GEOIP6_ASSET_KEY);
-
- if (fileGeoIP.exists()) {
- extraLines.append("GeoIPFile" + ' ').append(fileGeoIP.getCanonicalPath()).append('\n');
- extraLines.append("GeoIPv6File" + ' ').append(fileGeoIP6.getCanonicalPath()).append('\n');
- }
-
- if (!TextUtils.isEmpty(entranceNodes))
- extraLines.append("EntryNodes" + ' ').append(entranceNodes).append('\n');
-
- if (!TextUtils.isEmpty(exitNodes))
- extraLines.append("ExitNodes" + ' ').append(exitNodes).append('\n');
-
- if (!TextUtils.isEmpty(excludeNodes))
- extraLines.append("ExcludeNodes" + ' ').append(excludeNodes).append('\n');
-
- extraLines.append("StrictNodes" + ' ').append(enableStrictNodes ? "1" : "0").append('\n');
-
- try {
- if (ReachableAddresses) {
- String ReachableAddressesPorts = prefs.getString(OrbotConstants.PREF_REACHABLE_ADDRESSES_PORTS, "*:80,*:443");
- extraLines.append("ReachableAddresses" + ' ').append(ReachableAddressesPorts).append('\n');
- }
-
- } catch (Exception e) {
- showToolbarNotification(getString(R.string.your_reachableaddresses_settings_caused_an_exception_), ERROR_NOTIFY_ID, R.drawable.ic_stat_notifyerr);
- return null;
- }
-
- try {
- if (becomeRelay && (!useBridges) && (!ReachableAddresses)) {
- int ORPort = Integer.parseInt(Objects.requireNonNull(prefs.getString(OrbotConstants.PREF_OR_PORT, "9001")));
- String nickname = prefs.getString(OrbotConstants.PREF_OR_NICKNAME, "Orbot");
- String dnsFile = writeDNSFile();
-
- extraLines.append("ServerDNSResolvConfFile").append(' ').append(dnsFile).append('\n');
- extraLines.append("ORPort").append(' ').append(ORPort).append('\n');
- extraLines.append("Nickname").append(' ').append(nickname).append('\n');
- StringBuffer append = extraLines.append("ExitPolicy").append(' ').append("reject *:*").append('\n');
-
- }
- } catch (Exception e) {
- showToolbarNotification(getString(R.string.your_relay_settings_caused_an_exception_), ERROR_NOTIFY_ID, R.drawable.ic_stat_notifyerr);
- return null;
- }
-
- ContentResolver contentResolver = getApplicationContext().getContentResolver();
- addV3OnionServicesToTorrc(extraLines, contentResolver);
- addV3ClientAuthToTorrc(extraLines, contentResolver);
- addV2HiddenServicesToTorrc(extraLines, contentResolver);
- addV2ClientCookiesToTorrc(extraLines, contentResolver);
- return extraLines;
- }
-
- private void addV3OnionServicesToTorrc(StringBuffer torrc, ContentResolver contentResolver) {
- try {
- Cursor onionServices = contentResolver.query(V3_ONION_SERVICES_CONTENT_URI, V3_ONION_SERVICE_PROJECTION, OnionService.ENABLED + "=1", null, null);
- if (onionServices != null) {
- while (onionServices.moveToNext()) {
- int localPort = onionServices.getInt(onionServices.getColumnIndex(OnionService.PORT));
- int onionPort = onionServices.getInt(onionServices.getColumnIndex(OnionService.ONION_PORT));
- String v3DirPath = new File(mV3OnionBasePath.getAbsolutePath(), "v3" + localPort).getCanonicalPath();
- torrc.append("HiddenServiceDir ").append(v3DirPath).append("\n");
- torrc.append("HiddenServiceVersion 3").append("\n");
- torrc.append("HiddenServicePort ").append(onionPort).append(" 127.0.0.1:").append(localPort).append("\n");
- }
- onionServices.close();
- }
- } catch (Exception e) {
- Log.e(TAG, e.getLocalizedMessage());
- }
- }
-
- // todo needs modifications to set hidden service version back after doing v3 stuff...
- private void addV2HiddenServicesToTorrc(StringBuffer torrc, ContentResolver contentResolver) {
- try {
- Cursor hidden_services = contentResolver.query(V2_HS_CONTENT_URI, LEGACY_V2_ONION_SERVICE_PROJECTION, OnionService.ENABLED + "=1", null, null);
- if (hidden_services != null) {
- try {
- while (hidden_services.moveToNext()) {
- String HSname = hidden_services.getString(hidden_services.getColumnIndex(OnionService.NAME));
- int HSLocalPort = hidden_services.getInt(hidden_services.getColumnIndex(OnionService.PORT));
- int HSOnionPort = hidden_services.getInt(hidden_services.getColumnIndex(OnionService.ONION_PORT));
- int HSAuthCookie = hidden_services.getInt(hidden_services.getColumnIndex(OnionService.AUTH_COOKIE));
- String hsDirPath = new File(mHSBasePath.getAbsolutePath(), "hs" + HSLocalPort).getCanonicalPath();
-
- debug("Adding hidden service on port: " + HSLocalPort);
-
- torrc.append("HiddenServiceDir" + ' ' + hsDirPath).append('\n');
- torrc.append("HiddenServicePort" + ' ' + HSOnionPort + " 127.0.0.1:" + HSLocalPort).append('\n');
- torrc.append("HiddenServiceVersion 2").append('\n');
-
- if (HSAuthCookie == 1)
- torrc.append("HiddenServiceAuthorizeClient stealth " + HSname).append('\n');
- }
- } catch (NumberFormatException e) {
- Log.e(OrbotConstants.TAG, "error parsing hsport", e);
- } catch (Exception e) {
- Log.e(OrbotConstants.TAG, "error starting share server", e);
- }
-
- hidden_services.close();
- }
- } catch (SecurityException se) {
- }
- }
-
- public static String buildV3ClientAuthFile(String domain, String keyHash) {
- return domain + ":descriptor:x25519:" + keyHash;
- }
-
- private void addV3ClientAuthToTorrc(StringBuffer torrc, ContentResolver contentResolver) {
- Cursor v3auths = contentResolver.query(V3_CLIENT_AUTH_URI, V3_CLIENT_AUTH_PROJECTION, V3ClientAuth.ENABLED + "=1", null, null);
- if (v3auths != null) {
- for (File file : mV3AuthBasePath.listFiles()) {
- if (!file.isDirectory())
- file.delete(); // todo the adapter should maybe just write these files and not do this in service...
- }
- torrc.append("ClientOnionAuthDir " + mV3AuthBasePath.getAbsolutePath()).append('\n');
- try {
- int i = 0;
- while (v3auths.moveToNext()) {
- String domain = v3auths.getString(v3auths.getColumnIndex(V3ClientAuth.DOMAIN));
- String hash = v3auths.getString(v3auths.getColumnIndex(V3ClientAuth.HASH));
- File authFile = new File(mV3AuthBasePath, (i++) + ".auth_private");
- authFile.createNewFile();
- FileOutputStream fos = new FileOutputStream(authFile);
- fos.write(buildV3ClientAuthFile(domain, hash).getBytes());
- fos.close();
- }
- } catch (Exception e) {
- Log.e(TAG, "error adding v3 client auth...");
- }
- }
- }
-
- private void addV2ClientCookiesToTorrc(StringBuffer torrc, ContentResolver contentResolver) {
- try {
- Cursor client_cookies = contentResolver.query(COOKIE_CONTENT_URI, LEGACY_COOKIE_PROJECTION, ClientCookie.ENABLED + "=1", null, null);
- if (client_cookies != null) {
- try {
- while (client_cookies.moveToNext()) {
- String domain = client_cookies.getString(client_cookies.getColumnIndex(ClientCookie.DOMAIN));
- String cookie = client_cookies.getString(client_cookies.getColumnIndex(ClientCookie.AUTH_COOKIE_VALUE));
- torrc.append("HidServAuth" + ' ' + domain + ' ' + cookie).append('\n');
- }
- } catch (Exception e) {
- Log.e(OrbotConstants.TAG, "error starting share server", e);
- }
- client_cookies.close();
- }
- } catch (SecurityException se) {
- }
- }
-
- //using Google DNS for now as the public DNS server
- private String writeDNSFile() throws IOException {
- File file = new File(appBinHome, "resolv.conf");
-
- PrintWriter bw = new PrintWriter(new FileWriter(file));
- bw.println("nameserver 8.8.8.8");
- bw.println("nameserver 8.8.4.4");
- bw.close();
-
- return file.getCanonicalPath();
- }
-
- @SuppressLint("NewApi")
- @Override
- public void onTrimMemory(int level) {
- super.onTrimMemory(level);
-
- switch (level) {
- case TRIM_MEMORY_BACKGROUND:
- debug("trim memory requested: app in the background");
- break;
-
- case TRIM_MEMORY_COMPLETE:
- debug("trim memory requested: cleanup all memory");
- break;
-
- case TRIM_MEMORY_MODERATE:
- debug("trim memory requested: clean up some memory");
- break;
-
- case TRIM_MEMORY_RUNNING_CRITICAL:
- debug("trim memory requested: memory on device is very low and critical");
- break;
-
- case TRIM_MEMORY_RUNNING_LOW:
- debug("trim memory requested: memory on device is running low");
- break;
-
- case TRIM_MEMORY_RUNNING_MODERATE:
- debug("trim memory requested: memory on device is moderate");
- break;
-
- case TRIM_MEMORY_UI_HIDDEN:
- debug("trim memory requested: app is not showing UI anymore");
- break;
- }
- }
-
- @Override
- public IBinder onBind(Intent intent) {
- Log.e(TAG, "onBind");
- return super.onBind(intent); // invoking super class will call onRevoke() when appropriate
- }
-
- // system calls this method when VPN disconnects (either by the user or another VPN app)
- @Override
- public void onRevoke() {
- Prefs.putUseVpn(false);
- mVpnManager.handleIntent(new Builder(), new Intent(ACTION_STOP_VPN));
- // tell UI, if it's open, to update immediately (don't wait for onResume() in Activity...)
- LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent(ACTION_STOP_VPN));
- }
-
- private void setExitNode(String newExits) {
- SharedPreferences prefs = Prefs.getSharedPrefs(getApplicationContext());
-
- if (TextUtils.isEmpty(newExits)) {
- prefs.edit().remove("pref_exit_nodes").apply();
-
- if (conn != null) {
- try {
- ArrayList resetBuffer = new ArrayList<>();
- resetBuffer.add("ExitNodes");
- resetBuffer.add("StrictNodes");
- conn.resetConf(resetBuffer);
- conn.setConf("DisableNetwork", "1");
- conn.setConf("DisableNetwork", "0");
-
- } catch (Exception ioe) {
- Log.e(OrbotConstants.TAG, "Connection exception occured resetting exits", ioe);
- }
- }
- } else {
- prefs.edit().putString("pref_exit_nodes", newExits).apply();
-
- if (conn != null) {
- try {
- File fileGeoIP = new File(appBinHome, GEOIP_ASSET_KEY);
- File fileGeoIP6 = new File(appBinHome, GEOIP6_ASSET_KEY);
-
- conn.setConf("GeoIPFile", fileGeoIP.getCanonicalPath());
- conn.setConf("GeoIPv6File", fileGeoIP6.getCanonicalPath());
-
- conn.setConf("ExitNodes", newExits);
- conn.setConf("StrictNodes", "1");
-
- conn.setConf("DisableNetwork", "1");
- conn.setConf("DisableNetwork", "0");
-
- } catch (Exception ioe) {
- Log.e(OrbotConstants.TAG, "Connection exception occured resetting exits", ioe);
- }
- }
- }
-
- }
-
- private void loadBridgeDefaults() {
- if (alBridges == null) {
- alBridges = new ArrayList<>();
-
- try {
- BufferedReader in = new BufferedReader(new InputStreamReader(getResources().openRawResource(R.raw.bridges), "UTF-8"));
- String str;
-
- while ((str = in.readLine()) != null) {
-
- StringTokenizer st = new StringTokenizer(str, " ");
- Bridge b = new Bridge();
- b.type = st.nextToken();
-
- StringBuffer sbConfig = new StringBuffer();
-
- while (st.hasMoreTokens())
- sbConfig.append(st.nextToken()).append(' ');
-
- b.config = sbConfig.toString().trim();
- alBridges.add(b);
- }
-
- in.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- private void getBridges(String type, StringBuffer extraLines) {
-
- Collections.shuffle(alBridges, bridgeSelectRandom);
-
- //let's just pull up to 2 bridges from the defaults at time
- int maxBridges = 2;
- int bridgeCount = 0;
-
- //now go through the list to find the bridges we want
- for (Bridge b : alBridges) {
- if (b.type.equals(type)) {
- extraLines.append("Bridge ");
- extraLines.append(b.type);
- extraLines.append(' ');
- extraLines.append(b.config);
- extraLines.append('\n');
-
- bridgeCount++;
-
- if (bridgeCount > maxBridges)
- break;
- }
- }
- }
-
- public static final class OnionService implements BaseColumns {
- public static final String NAME = "name";
- public static final String PORT = "port";
- public static final String ONION_PORT = "onion_port";
- public static final String DOMAIN = "domain";
- public static final String AUTH_COOKIE = "auth_cookie";
- public static final String AUTH_COOKIE_VALUE = "auth_cookie_value";
- public static final String ENABLED = "enabled";
- }
-
- public static final class V3ClientAuth implements BaseColumns {
- public static final String DOMAIN = "domain";
- public static final String HASH = "hash";
- public static final String ENABLED = "enabled";
- }
-
- public static final class ClientCookie implements BaseColumns {
- public static final String DOMAIN = "domain";
- public static final String AUTH_COOKIE_VALUE = "auth_cookie_value";
- public static final String ENABLED = "enabled";
- }
-
- // for bridge loading from the assets default bridges.txt file
- static class Bridge {
- String type;
- String config;
- }
-
- private class IncomingIntentRouter implements Runnable {
- Intent mIntent;
-
- public IncomingIntentRouter(Intent intent) {
- mIntent = intent;
- }
-
- public void run() {
- String action = mIntent.getAction();
-
- if (!TextUtils.isEmpty(action)) {
- if (action.equals(ACTION_START) || action.equals(ACTION_START_ON_BOOT)) {
-
- if (useIPtObfsMeekProxy())
- IPtProxy.startObfs4Proxy("DEBUG", false, false);
-
- if (useIPtSnowflakeProxy())
- startSnowflakeClient();
-
- if (Prefs.beSnowflakeProxy())
- runSnowflakeProxy();
-
- startTor();
- replyWithStatus(mIntent);
-
- if (Prefs.useVpn()) {
- if (mVpnManager != null
- && (!mVpnManager.isStarted())) {
- //start VPN here
- Intent vpnIntent = VpnService.prepare(OrbotService.this);
- if (vpnIntent == null) //then we can run the VPN
- {
- mVpnManager.handleIntent(new Builder(), mIntent);
-
- }
- }
-
- if (mPortSOCKS != -1 && mPortHTTP != -1)
- sendCallbackPorts(mPortSOCKS, mPortHTTP, mPortDns, mPortTrans);
- }
-
- } else if (action.equals(ACTION_START_VPN)) {
- if (mVpnManager != null && (!mVpnManager.isStarted())) {
- //start VPN here
- Intent vpnIntent = VpnService.prepare(OrbotService.this);
- if (vpnIntent == null) { //then we can run the VPN
- mVpnManager.handleIntent(new Builder(), mIntent);
- }
- }
-
- if (mPortSOCKS != -1 && mPortHTTP != -1)
- sendCallbackPorts(mPortSOCKS, mPortHTTP, mPortDns, mPortTrans);
-
-
- } else if (action.equals(ACTION_STOP_VPN)) {
- if (mVpnManager != null)
- mVpnManager.handleIntent(new Builder(), mIntent);
- } else if (action.equals(ACTION_STATUS)) {
- replyWithStatus(mIntent);
- } else if (action.equals(CMD_SIGNAL_HUP)) {
- requestTorRereadConfig();
- } else if (action.equals(CMD_NEWNYM)) {
- newIdentity();
- } else if (action.equals(CMD_ACTIVE)) {
- sendSignalActive();
- } else if (action.equals(CMD_SET_EXIT)) {
- setExitNode(mIntent.getStringExtra("exit"));
- } else {
- Log.w(OrbotConstants.TAG, "unhandled OrbotService Intent: " + action);
- }
- }
- }
- }
-
- private int mNetworkType = -1;
- private final BroadcastReceiver mNetworkStateReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
-
- SharedPreferences prefs = Prefs.getSharedPrefs(getApplicationContext());
-
- if(prefs==null){
- }
-
- boolean doNetworKSleep = prefs.getBoolean(OrbotConstants.PREF_DISABLE_NETWORK, true);
-
- final ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
- final NetworkInfo netInfo = cm.getActiveNetworkInfo();
-
- boolean newConnectivityState = false;
- int newNetType = -1;
-
- if (netInfo!=null)
- newNetType = netInfo.getType();
-
- if(netInfo != null && netInfo.isConnected()) {
- // WE ARE CONNECTED: DO SOMETHING
- newConnectivityState = true;
- }
- else {
- // WE ARE NOT: DO SOMETHING ELSE
- newConnectivityState = false;
- }
-
- mNetworkType = newNetType;
-
- if (newConnectivityState != mConnectivity) {
- mConnectivity = newConnectivityState;
- orbotLocalConstants.mNetworkState = mConnectivity;
-
- if (mConnectivity)
- newIdentity();
- }
-
-
- if (doNetworKSleep)
- {
- //setTorNetworkEnabled (mConnectivity);
- if (!mConnectivity)
- {
- //sendCallbackStatus(STATUS_OFF);
- orbotLocalConstants.mTorLogsStatus = "No internet connection";
- showToolbarNotification(getString(R.string.newnym), getNotifyId(), R.drawable.ic_stat_tor_off);
- showToolbarNotification(context.getString(R.string.no_network_connectivity_putting_tor_to_sleep_),NOTIFY_ID,R.drawable.ic_stat_tor_off);
- }
- else
- {
- //sendCallbackStatus(STATUS_STARTING);
- logNotice(context.getString(R.string.network_connectivity_is_good_waking_tor_up_));
- showToolbarNotification(getString(R.string.status_activated),NOTIFY_ID,R.drawable.ic_stat_starting_tor_logo);
- }
-
- }
- }
- };
-
-
- public int getNotifyId() {
- return NOTIFY_ID;
- }
- private static OrbotService self = null;
-
- public static OrbotService getServiceObject(){
- return self;
- }
-
- public void disableNotification(){
- if(mNotificationManager!=null){
- mNotificationManager.cancel(NOTIFY_ID);
- stopForeground(true);
- }
- }
-
- public void enableTorNotificationNoBandwidth(){
- showToolbarNotification("Connected to the Tor network", HS_NOTIFY_ID, R.drawable.ic_stat_tor_logo);
- }
-
- public void enableNotification(){
- showToolbarNotification(0+"kbps ⇣ / " +0+"kbps ⇡", HS_NOTIFY_ID, R.drawable.ic_stat_tor_logo);
- }
-
- private class ActionBroadcastReceiver extends BroadcastReceiver {
- public void onReceive(Context context, Intent intent) {
- switch (intent.getAction()) {
- case CMD_NEWNYM: {
- newIdentity();
- break;
- }
- case CMD_ACTIVE: {
- sendSignalActive();
- break;
- }
- }
- }
- }
-}
diff --git a/orbotOld/src/main/java/org/torproject/android/service/StartTorReceiver.java b/orbotOld/src/main/java/org/torproject/android/service/StartTorReceiver.java
deleted file mode 100644
index 3fb77e91..00000000
--- a/orbotOld/src/main/java/org/torproject/android/service/StartTorReceiver.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.torproject.android.service;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Build;
-import android.text.TextUtils;
-
-import org.torproject.android.service.util.Prefs;
-
-
-public class StartTorReceiver extends BroadcastReceiver implements TorServiceConstants {
-
- @Override
- public void onReceive(Context context, Intent intent) {
- /* sanitize the Intent before forwarding it to OrbotService */
- Prefs.setContext(context);
- String action = intent.getAction();
- if (TextUtils.equals(action, ACTION_START)) {
- String packageName = intent.getStringExtra(EXTRA_PACKAGE_NAME);
- if (Prefs.allowBackgroundStarts()) {
- Intent startTorIntent = new Intent(context, OrbotService.class);
- startTorIntent.setAction(action);
- if (packageName != null) {
- startTorIntent.putExtra(OrbotService.EXTRA_PACKAGE_NAME, packageName);
- }
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && Prefs.persistNotifications()) {
- context.startForegroundService(startTorIntent);
- } else {
- context.startService(startTorIntent);
- }
- } else if (!TextUtils.isEmpty(packageName)) {
- // let the requesting app know that the user has disabled
- // starting via Intent
- Intent startsDisabledIntent = new Intent(ACTION_STATUS);
- startsDisabledIntent.putExtra(EXTRA_STATUS, STATUS_STARTS_DISABLED);
- startsDisabledIntent.setPackage(packageName);
- context.sendBroadcast(startsDisabledIntent);
- }
- }
- }
-}
diff --git a/orbotOld/src/main/java/org/torproject/android/service/TorEventHandler.java b/orbotOld/src/main/java/org/torproject/android/service/TorEventHandler.java
deleted file mode 100644
index cd141362..00000000
--- a/orbotOld/src/main/java/org/torproject/android/service/TorEventHandler.java
+++ /dev/null
@@ -1,252 +0,0 @@
-package org.torproject.android.service;
-
-import android.text.TextUtils;
-
-import androidx.core.app.NotificationCompat;
-
-import net.freehaven.tor.control.EventHandler;
-
-import org.torproject.android.service.util.ExternalIPFetcher;
-import org.torproject.android.service.util.Prefs;
-import org.torproject.android.service.wrapper.orbotLocalConstants;
-
-import java.text.NumberFormat;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.StringTokenizer;
-
-/**
- * Created by n8fr8 on 9/25/16.
- */
-public class TorEventHandler implements EventHandler, TorServiceConstants {
-
- private final static int BW_THRESDHOLD = 10000;
- private OrbotService mService;
- private long lastRead = -1;
- private long lastWritten = -1;
- private long mTotalTrafficWritten = 0;
- private long mTotalTrafficRead = 0;
- private NumberFormat mNumberFormat;
- private HashMap hmBuiltNodes = new HashMap<>();
-
- public TorEventHandler(OrbotService service) {
- mService = service;
- mNumberFormat = NumberFormat.getInstance(Locale.getDefault()); //localized numbers!
-
- }
-
- public HashMap getNodes() {
- return hmBuiltNodes;
- }
-
- @Override
- public void message(String severity, String msg) {
-
- if (severity.equalsIgnoreCase("debug"))
- mService.debug(severity + ": " + msg);
- else
- mService.logNotice(severity + ": " + msg);
- }
-
- @Override
- public void newDescriptors(List orList) {
-
- for (String desc : orList)
- mService.debug("descriptors: " + desc);
-
- }
-
- @Override
- public void orConnStatus(String status, String orName) {
-
- String sb = "orConnStatus (" +
- parseNodeName(orName) +
- "): " +
- status;
- mService.debug(sb);
- }
-
- @Override
- public void streamStatus(String status, String streamID, String target) {
-
- String sb = "StreamStatus (" +
- (streamID) +
- "): " +
- status;
- mService.debug(sb);
- }
-
- @Override
- public void unrecognized(String type, String msg) {
-
- String sb = "Message (" +
- type +
- "): " +
- msg;
- mService.logNotice(sb);
- }
-
- @Override
- public void bandwidthUsed(long read, long written) {
-
- if (lastWritten > BW_THRESDHOLD || lastRead > BW_THRESDHOLD) {
-
- int iconId = R.drawable.ic_stat_tor_logo;
-
- if (read > 0 || written > 0){
- if(orbotLocalConstants.mIsTorInitialized){
- iconId = R.drawable.ic_stat_tor_logo;
- }else {
- iconId = R.drawable.ic_stat_starting_tor_logo;
- }
- }
-
- String sb = formatCount(read) +
- " \u2193" +
- " / " +
- formatCount(written) +
- " \u2191";
- mService.showToolbarNotification(sb, mService.getNotifyId(), iconId);
-
- mTotalTrafficWritten += written;
- mTotalTrafficRead += read;
-
- mService.sendCallbackBandwidth(lastWritten, lastRead, mTotalTrafficWritten, mTotalTrafficRead);
-
- lastWritten = 0;
- lastRead = 0;
- }
-
- lastWritten += written;
- lastRead += read;
-
- }
-
- private String formatCount(long count) {
- // Converts the supplied argument into a string.
-
- // Under 2Mb, returns "xxx.xKb"
- // Over 2Mb, returns "xxx.xxMb"
- if (mNumberFormat != null)
- if (count < 1e6)
- return mNumberFormat.format(Math.round((float) ((int) (count * 10 / 1024)) / 10)) + "kbps";
- else
- return mNumberFormat.format(Math.round((float) ((int) (count * 100 / 1024 / 1024)) / 100)) + "mbps";
- else
- return "";
-
- //return count+" kB";
- }
-
- public void circuitStatus(String status, String circID, String path) {
-
- /* once the first circuit is complete, then announce that Orbot is on*/
- if (mService.getCurrentStatus() == STATUS_STARTING && TextUtils.equals(status, "BUILT")) {
- mService.sendCallbackStatus(STATUS_ON);
- }
-
- if (Prefs.useDebugLogging()) {
- StringBuilder sb = new StringBuilder();
- sb.append("Circuit (");
- sb.append((circID));
- sb.append(") ");
- sb.append(status);
- sb.append(": ");
-
- StringTokenizer st = new StringTokenizer(path, ",");
- Node node;
-
- boolean isFirstNode = true;
- int nodeCount = st.countTokens();
-
- while (st.hasMoreTokens()) {
- String nodePath = st.nextToken();
- String nodeId = null, nodeName = null;
-
- String[] nodeParts;
-
- if (nodePath.contains("="))
- nodeParts = nodePath.split("=");
- else
- nodeParts = nodePath.split("~");
-
- if (nodeParts.length == 1) {
- nodeId = nodeParts[0].substring(1);
- nodeName = nodeId;
- } else if (nodeParts.length == 2) {
- nodeId = nodeParts[0].substring(1);
- nodeName = nodeParts[1];
- }
-
- if (nodeId == null)
- continue;
-
- node = hmBuiltNodes.get(nodeId);
-
- if (node == null) {
- node = new Node();
- node.id = nodeId;
- node.name = nodeName;
- }
-
- node.status = status;
-
- sb.append(node.name);
-
- if (!TextUtils.isEmpty(node.ipAddress))
- sb.append("(").append(node.ipAddress).append(")");
-
- if (st.hasMoreTokens())
- sb.append(" > ");
-
- if (status.equals("EXTENDED")) {
-
- if (isFirstNode) {
- hmBuiltNodes.put(node.id, node);
-
- if (node.ipAddress == null && (!node.isFetchingInfo) && Prefs.useDebugLogging()) {
- node.isFetchingInfo = true;
- mService.exec(new ExternalIPFetcher(mService, node, OrbotService.mPortHTTP));
- }
-
- isFirstNode = false;
- }
- } else if (status.equals("BUILT")) {
- // mService.logNotice(sb.toString());
-
- if (Prefs.useDebugLogging() && nodeCount > 3)
- mService.debug(sb.toString());
- } else if (status.equals("CLOSED")) {
- // mService.logNotice(sb.toString());
- hmBuiltNodes.remove(node.id);
- }
-
- }
-
-
- }
-
-
- }
-
- private String parseNodeName(String node) {
- if (node.indexOf('=') != -1) {
- return (node.substring(node.indexOf("=") + 1));
- } else if (node.indexOf('~') != -1) {
- return (node.substring(node.indexOf("~") + 1));
- } else
- return node;
- }
-
- public static class Node {
- public String status;
- public String id;
- public String name;
- public String ipAddress;
- public String country;
- public String organization;
-
- public boolean isFetchingInfo = false;
- }
-}
diff --git a/orbotOld/src/main/java/org/torproject/android/service/TorServiceConstants.java b/orbotOld/src/main/java/org/torproject/android/service/TorServiceConstants.java
deleted file mode 100644
index e69d8ba6..00000000
--- a/orbotOld/src/main/java/org/torproject/android/service/TorServiceConstants.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/* Copyright (c) 2009, Nathan Freitas, Orbot / The Guardian Project - http://openideals.com/guardian */
-/* See LICENSE for licensing information */
-
-package org.torproject.android.service;
-
-import android.content.Intent;
-
-public interface TorServiceConstants {
-
- String DIRECTORY_TOR_DATA = "tordata";
-
- String TOR_CONTROL_PORT_FILE = "control.txt";
- String TOR_PID_FILE = "torpid";
-
- //torrc (tor config file)
- String TORRC_ASSET_KEY = "torrc";
-
- String TOR_CONTROL_COOKIE = "control_auth_cookie";
-
- //geoip data file asset key
- String GEOIP_ASSET_KEY = "geoip";
- String GEOIP6_ASSET_KEY = "geoip6";
-
- String IP_LOCALHOST = "127.0.0.1";
- int TOR_TRANSPROXY_PORT_DEFAULT = 9040;
-
- int TOR_DNS_PORT_DEFAULT = 5400;
-
- String HTTP_PROXY_PORT_DEFAULT = "8118"; // like Privoxy!
- String SOCKS_PROXY_PORT_DEFAULT = "9050";
-
- //control port
- String LOG_NOTICE_HEADER = "NOTICE";
- String LOG_NOTICE_BOOTSTRAPPED = "Bootstrapped";
-
- /**
- * A request to Orbot to transparently start Tor services
- */
- String ACTION_START = "org.torproject.android.intent.action.START";
- String ACTION_STOP = "org.torproject.android.intent.action.STOP";
-
- String ACTION_START_VPN = "org.torproject.android.intent.action.START_VPN";
- String ACTION_STOP_VPN = "org.torproject.android.intent.action.STOP_VPN";
-
- String ACTION_START_ON_BOOT = "org.torproject.android.intent.action.START_BOOT";
-
- int REQUEST_VPN = 7777;
-
- /**
- * {@link Intent} send by Orbot with {@code ON/OFF/STARTING/STOPPING} status
- */
- String ACTION_STATUS = "org.torproject.android.intent.action.STATUS";
- /**
- * {@code String} that contains a status constant: {@link #STATUS_ON},
- * {@link #STATUS_OFF}, {@link #STATUS_STARTING}, or
- * {@link #STATUS_STOPPING}
- */
- String EXTRA_STATUS = "org.torproject.android.intent.extra.STATUS";
- /**
- * A {@link String} {@code packageName} for Orbot to direct its status reply
- * to, used in {@link #ACTION_START} {@link Intent}s sent to Orbot
- */
- String EXTRA_PACKAGE_NAME = "org.torproject.android.intent.extra.PACKAGE_NAME";
- /**
- * The SOCKS proxy settings in URL form.
- */
- String EXTRA_SOCKS_PROXY = "org.torproject.android.intent.extra.SOCKS_PROXY";
- String EXTRA_SOCKS_PROXY_HOST = "org.torproject.android.intent.extra.SOCKS_PROXY_HOST";
- String EXTRA_SOCKS_PROXY_PORT = "org.torproject.android.intent.extra.SOCKS_PROXY_PORT";
- /**
- * The HTTP proxy settings in URL form.
- */
- String EXTRA_HTTP_PROXY = "org.torproject.android.intent.extra.HTTP_PROXY";
- String EXTRA_HTTP_PROXY_HOST = "org.torproject.android.intent.extra.HTTP_PROXY_HOST";
- String EXTRA_HTTP_PROXY_PORT = "org.torproject.android.intent.extra.HTTP_PROXY_PORT";
-
- String EXTRA_DNS_PORT = "org.torproject.android.intent.extra.DNS_PORT";
- String EXTRA_TRANS_PORT = "org.torproject.android.intent.extra.TRANS_PORT";
-
- String LOCAL_ACTION_LOG = "log";
- String LOCAL_ACTION_BANDWIDTH = "bandwidth";
- String LOCAL_EXTRA_LOG = "log";
- String LOCAL_ACTION_PORTS = "ports";
-
- /**
- * All tor-related services and daemons are stopped
- */
- String STATUS_OFF = "OFF";
- /**
- * All tor-related services and daemons have completed starting
- */
- String STATUS_ON = "ON";
- String STATUS_STARTING = "STARTING";
- String STATUS_STOPPING = "STOPPING";
-
- /**
- * The user has disabled the ability for background starts triggered by
- * apps. Fallback to the old {@link Intent} action that brings up Orbot:
- * {@link org.torproject.android.OrbotMainActivity#INTENT_ACTION_REQUEST_START_TOR}
- */
- String STATUS_STARTS_DISABLED = "STARTS_DISABLED";
-
- // actions for internal command Intents
- String CMD_SIGNAL_HUP = "signal_hup";
- String CMD_NEWNYM = "newnym";
- String CMD_SET_EXIT = "setexit";
- String CMD_ACTIVE = "ACTIVE";
-
- String PREF_BINARY_TOR_VERSION_INSTALLED = "BINARY_TOR_VERSION_INSTALLED";
-
- //obfsproxy
- String OBFSCLIENT_ASSET_KEY = "obfs4proxy";
-
- String HIDDEN_SERVICES_DIR = "hidden_services";
- String ONION_SERVICES_DIR = "v3_onion_services";
- String V3_CLIENT_AUTH_DIR = "v3_client_auth";
-
-}
diff --git a/orbotOld/src/main/java/org/torproject/android/service/util/CustomNativeLoader.java b/orbotOld/src/main/java/org/torproject/android/service/util/CustomNativeLoader.java
deleted file mode 100644
index fb528621..00000000
--- a/orbotOld/src/main/java/org/torproject/android/service/util/CustomNativeLoader.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package org.torproject.android.service.util;
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.os.Build;
-import android.util.Log;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-public class CustomNativeLoader {
-
- private final static String TAG = "CNL";
-
- @SuppressLint("SetWorldReadable")
- private static boolean loadFromZip(Context context, String libname, File destLocalFile, String arch) {
-
-
- ZipFile zipFile = null;
- InputStream stream = null;
-
- try {
- zipFile = new ZipFile(context.getApplicationInfo().sourceDir);
- ZipEntry entry = zipFile.getEntry("lib/" + arch + "/" + libname + ".so");
- if (entry == null) {
- entry = zipFile.getEntry("jni/" + arch + "/" + libname + ".so");
- if (entry == null)
- throw new Exception("Unable to find file in apk:" + "lib/" + arch + "/" + libname);
- }
-
- //how we wrap this in another stream because the native .so is zipped itself
- stream = zipFile.getInputStream(entry);
-
- OutputStream out = new FileOutputStream(destLocalFile);
- byte[] buf = new byte[4096];
- int len;
- while ((len = stream.read(buf)) > 0) {
- Thread.yield();
- out.write(buf, 0, len);
- }
- out.close();
-
- destLocalFile.setReadable(true, false);
- destLocalFile.setExecutable(true, false);
- destLocalFile.setWritable(true);
-
- return true;
- } catch (Exception e) {
- Log.e(TAG, e.getMessage());
- } finally {
- if (stream != null) {
- try {
- stream.close();
- } catch (Exception e) {
- Log.e(TAG, e.getMessage());
- }
- }
- if (zipFile != null) {
- try {
- zipFile.close();
- } catch (Exception e) {
- Log.e(TAG, e.getMessage());
- }
- }
- }
- return false;
- }
-
- public static File loadNativeBinary(Context context, String libname, File destLocalFile) {
-
- try {
-
-
- File fileNativeBin = new File(getNativeLibraryDir(context), libname + ".so");
- if (!fileNativeBin.exists())
- fileNativeBin = new File(getNativeLibraryDir(context), "lib" + libname + ".so");
-
- if (fileNativeBin.exists()) {
- if (fileNativeBin.canExecute())
- return fileNativeBin;
- else {
- setExecutable(fileNativeBin);
-
- if (fileNativeBin.canExecute())
- return fileNativeBin;
- }
- }
-
- String folder = Build.CPU_ABI;
-
-
- String javaArch = System.getProperty("os.arch");
- if (javaArch != null && javaArch.contains("686")) {
- folder = "x86";
- }
-
- if (loadFromZip(context, libname, destLocalFile, folder)) {
- return destLocalFile;
- }
-
- } catch (Throwable e) {
- Log.e(TAG, e.getMessage(), e);
- }
-
-
- return null;
- }
-
- private static void setExecutable(File fileBin) {
- fileBin.setReadable(true);
- fileBin.setExecutable(true);
- fileBin.setWritable(false);
- fileBin.setWritable(true, true);
- }
-
- // Return Full path to the directory where native JNI libraries are stored.
- private static String getNativeLibraryDir(Context context) {
- ApplicationInfo appInfo = context.getApplicationInfo();
- return appInfo.nativeLibraryDir;
- }
-
-}
-
diff --git a/orbotOld/src/main/java/org/torproject/android/service/util/CustomShell.java b/orbotOld/src/main/java/org/torproject/android/service/util/CustomShell.java
deleted file mode 100644
index 8f50ccf2..00000000
--- a/orbotOld/src/main/java/org/torproject/android/service/util/CustomShell.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.torproject.android.service.util;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.annotation.WorkerThread;
-
-import com.jaredrummler.android.shell.CommandResult;
-import com.jaredrummler.android.shell.Shell;
-import com.jaredrummler.android.shell.ShellExitCode;
-import com.jaredrummler.android.shell.StreamGobbler;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-public class CustomShell extends Shell {
-
-
- @WorkerThread
- public static CommandResult run(@NonNull String shell, boolean waitFor, @Nullable Map env, @NonNull String command) {
- List stdout = Collections.synchronizedList(new ArrayList<>());
- List stderr = Collections.synchronizedList(new ArrayList<>());
- int exitCode = -1;
-
- try {
-
- // setup our process, retrieve stdin stream, and stdout/stderr gobblers
- //Process process = runWithEnv(command, env);
- ProcessBuilder builder = new ProcessBuilder();
-
- if (env != null && (!env.isEmpty()))
- builder.environment().putAll(env);
-
- builder.command("/system/bin/" + shell, "-c", command);
- Process process = builder.start();
-
- StreamGobbler stdoutGobbler = null;
- StreamGobbler stderrGobbler = null;
-
- if (waitFor) {
- stdoutGobbler = new StreamGobbler(process.getInputStream(), stdout);
- stderrGobbler = new StreamGobbler(process.getErrorStream(), stderr);
-
- // start gobbling and write our commands to the shell
- stdoutGobbler.start();
- stderrGobbler.start();
- }
-
- // wait for our process to finish, while we gobble away in the background
- if (waitFor)
- exitCode = process.waitFor();
- else
- exitCode = 0;
-
- // make sure our threads are done gobbling, our streams are closed, and the process is destroyed - while the
- // latter two shouldn't be needed in theory, and may even produce warnings, in "normal" Java they are required
- // for guaranteed cleanup of resources, so lets be safe and do this on Android as well
- /**
- try {
- stdin.close();
- } catch (IOException e) {
- // might be closed already
- }**/
-
- if (waitFor) {
- stdoutGobbler.join();
- stderrGobbler.join();
- }
-
- } catch (InterruptedException e) {
- exitCode = ShellExitCode.WATCHDOG_EXIT;
- } catch (IOException e) {
- exitCode = ShellExitCode.SHELL_WRONG_UID;
- }
-
- return new CommandResult(stdout, stderr, exitCode);
- }
-}
diff --git a/orbotOld/src/main/java/org/torproject/android/service/util/CustomTorResourceInstaller.java b/orbotOld/src/main/java/org/torproject/android/service/util/CustomTorResourceInstaller.java
deleted file mode 100644
index 8bec9ccc..00000000
--- a/orbotOld/src/main/java/org/torproject/android/service/util/CustomTorResourceInstaller.java
+++ /dev/null
@@ -1,184 +0,0 @@
-package org.torproject.android.service.util;
-
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.util.Log;
-
-import org.torproject.android.binary.TorServiceConstants;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.concurrent.TimeoutException;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-
-public class CustomTorResourceInstaller implements TorServiceConstants {
-
-
- private File installFolder;
- private Context context;
-
- private File fileTorrc;
- private File fileTor;
-
- public CustomTorResourceInstaller(Context context, File installFolder) {
- this.installFolder = installFolder;
- this.context = context;
- }
-
- // Return Full path to the directory where native JNI libraries are stored.
- private static String getNativeLibraryDir(Context context) {
- ApplicationInfo appInfo = context.getApplicationInfo();
- return appInfo.nativeLibraryDir;
- }
-
- /*
- * Write the inputstream contents to the file
- */
- private static boolean streamToFile(InputStream stm, File outFile, boolean append, boolean zip) throws IOException {
- byte[] buffer = new byte[FILE_WRITE_BUFFER_SIZE];
-
- int bytecount;
-
- OutputStream stmOut = new FileOutputStream(outFile.getAbsolutePath(), append);
- ZipInputStream zis = null;
-
- if (zip) {
- zis = new ZipInputStream(stm);
- ZipEntry ze = zis.getNextEntry();
- stm = zis;
-
- }
-
- while ((bytecount = stm.read(buffer)) > 0) {
-
- stmOut.write(buffer, 0, bytecount);
-
- }
-
- stmOut.close();
- stm.close();
-
- if (zis != null)
- zis.close();
-
-
- return true;
-
- }
-
-
-
-
- /*
- * Extract the Tor binary from the APK file using ZIP
- */
-
- private static File[] listf(String directoryName) {
-
- // .............list file
- File directory = new File(directoryName);
-
- // get all the files from a directory
- File[] fList = directory.listFiles();
-
- if (fList != null)
- for (File file : fList) {
- if (file.isFile()) {
- Log.d(TAG, file.getAbsolutePath());
- } else if (file.isDirectory()) {
- listf(file.getAbsolutePath());
- }
- }
-
- return fList;
- }
-
- //
- /*
- * Extract the Tor resources from the APK file using ZIP
- *
- * @File path to the Tor executable
- */
- public File installResources() throws IOException, TimeoutException {
-
- fileTor = new File(installFolder, TOR_ASSET_KEY);
-
- if (!installFolder.exists())
- installFolder.mkdirs();
-
- installGeoIP();
- fileTorrc = assetToFile(COMMON_ASSET_KEY + TORRC_ASSET_KEY, TORRC_ASSET_KEY, false, false);
-
- File fileNativeDir = new File(getNativeLibraryDir(context));
- fileTor = new File(fileNativeDir, TOR_ASSET_KEY + ".so");
-
- if (fileTor.exists()) {
- if (fileTor.canExecute())
- return fileTor;
- else {
- setExecutable(fileTor);
-
- if (fileTor.canExecute())
- return fileTor;
- }
- }
-
- File fileTorBin = new File(installFolder, TOR_BINARY_KEY);
-
- //it exists but we can't execute it, so copy it to a new path
- if (fileTor.exists()) {
- InputStream is = new FileInputStream(fileTor);
- streamToFile(is, fileTorBin, false, true);
- setExecutable(fileTorBin);
-
- if (fileTorBin.exists() && fileTorBin.canExecute())
- return fileTorBin;
- }
-
- //let's try another approach
- fileTor = CustomNativeLoader.loadNativeBinary(context, TOR_ASSET_KEY, fileTorBin);
-
- if (fileTor != null && fileTor.exists())
- setExecutable(fileTor);
-
- if (fileTor != null && fileTor.exists() && fileTor.canExecute())
- return fileTor;
-
- return null;
- }
-
- private boolean installGeoIP() throws IOException {
-
- assetToFile(COMMON_ASSET_KEY + GEOIP_ASSET_KEY, GEOIP_ASSET_KEY, false, false);
-
- assetToFile(COMMON_ASSET_KEY + GEOIP6_ASSET_KEY, GEOIP6_ASSET_KEY, false, false);
-
- return true;
- }
-
- /*
- * Reads file from assetPath/assetKey writes it to the install folder
- */
- private File assetToFile(String assetPath, String assetKey, boolean isZipped, boolean isExecutable) throws IOException {
- InputStream is = context.getAssets().open(assetPath);
- File outFile = new File(installFolder, assetKey);
- streamToFile(is, outFile, false, isZipped);
- if (isExecutable) {
- setExecutable(outFile);
- }
- return outFile;
- }
-
- private void setExecutable(File fileBin) {
- fileBin.setReadable(true);
- fileBin.setExecutable(true);
- fileBin.setWritable(false);
- fileBin.setWritable(true, true);
- }
-}
-
diff --git a/orbotOld/src/main/java/org/torproject/android/service/util/DummyActivity.java b/orbotOld/src/main/java/org/torproject/android/service/util/DummyActivity.java
deleted file mode 100644
index c818c96f..00000000
--- a/orbotOld/src/main/java/org/torproject/android/service/util/DummyActivity.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.torproject.android.service.util;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-/*
- * To combat background service being stopped/swiped
- */
-public class DummyActivity extends Activity {
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- finish();
- }
-}
\ No newline at end of file
diff --git a/orbotOld/src/main/java/org/torproject/android/service/util/ExternalIPFetcher.java b/orbotOld/src/main/java/org/torproject/android/service/util/ExternalIPFetcher.java
deleted file mode 100644
index 957e1e65..00000000
--- a/orbotOld/src/main/java/org/torproject/android/service/util/ExternalIPFetcher.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package org.torproject.android.service.util;
-
-import org.json.JSONArray;
-import org.json.JSONObject;
-import org.torproject.android.service.OrbotService;
-import org.torproject.android.service.TorEventHandler;
-
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.InetSocketAddress;
-import java.net.Proxy;
-import java.net.URL;
-import java.net.URLConnection;
-
-public class ExternalIPFetcher implements Runnable {
-
- private final static String ONIONOO_BASE_URL = "https://onionoo.torproject.org/details?fields=country_name,as_name,or_addresses&lookup=";
- private OrbotService mService;
- private TorEventHandler.Node mNode;
- private int mLocalHttpProxyPort = 8118;
-
- public ExternalIPFetcher(OrbotService service, TorEventHandler.Node node, int localProxyPort) {
- mService = service;
- mNode = node;
- mLocalHttpProxyPort = localProxyPort;
- }
-
- public void run() {
- try {
-
- URLConnection conn;
-
- Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", mLocalHttpProxyPort));
- conn = new URL(ONIONOO_BASE_URL + mNode.id).openConnection(proxy);
-
- conn.setRequestProperty("Connection", "Close");
- conn.setConnectTimeout(60000);
- conn.setReadTimeout(60000);
-
- InputStream is = conn.getInputStream();
-
- BufferedReader reader = new BufferedReader(new InputStreamReader(is));
-
- // getting JSON string from URL
-
- StringBuffer json = new StringBuffer();
- String line;
-
- while ((line = reader.readLine()) != null)
- json.append(line);
-
- JSONObject jsonNodeInfo = new org.json.JSONObject(json.toString());
-
- JSONArray jsonRelays = jsonNodeInfo.getJSONArray("relays");
-
- if (jsonRelays.length() > 0) {
- mNode.ipAddress = jsonRelays.getJSONObject(0).getJSONArray("or_addresses").getString(0).split(":")[0];
- mNode.country = jsonRelays.getJSONObject(0).getString("country_name");
- mNode.organization = jsonRelays.getJSONObject(0).getString("as_name");
-
- StringBuffer sbInfo = new StringBuffer();
- sbInfo.append(mNode.name).append("(");
- sbInfo.append(mNode.ipAddress).append(")");
-
- if (mNode.country != null)
- sbInfo.append(' ').append(mNode.country);
-
- if (mNode.organization != null)
- sbInfo.append(" (").append(mNode.organization).append(')');
-
- mService.debug(sbInfo.toString());
-
- }
-
- reader.close();
- is.close();
-
-
- } catch (Exception e) {
-
- // mService.debug ("Error getting node details from onionoo: " + e.getMessage());
- }
- }
-}
diff --git a/orbotOld/src/main/java/org/torproject/android/service/util/NativeLoader.java b/orbotOld/src/main/java/org/torproject/android/service/util/NativeLoader.java
deleted file mode 100644
index c870025a..00000000
--- a/orbotOld/src/main/java/org/torproject/android/service/util/NativeLoader.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package org.torproject.android.service.util;
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.os.Build;
-import android.util.Log;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-public class NativeLoader {
-
- private final static String TAG = "TorNativeLoader";
-
- @SuppressLint("SetWorldReadable")
- private static boolean loadFromZip(Context context, String libName, File destLocalFile, String folder) {
-
-
- ZipFile zipFile = null;
- InputStream stream = null;
- try {
- zipFile = new ZipFile(context.getApplicationInfo().sourceDir);
-
- /**
- Enumeration extends ZipEntry> entries = zipFile.entries();
- while (entries.hasMoreElements())
- {
- ZipEntry entry = entries.nextElement();
- Log.d("Zip","entry: " + entry.getName());
- }
- **/
-
- ZipEntry entry = zipFile.getEntry("lib/" + folder + "/" + libName + ".so");
- if (entry == null) {
- entry = zipFile.getEntry("lib/" + folder + "/" + libName);
- if (entry == null)
- throw new Exception("Unable to find file in apk:" + "lib/" + folder + "/" + libName);
- }
- stream = zipFile.getInputStream(entry);
-
- OutputStream out = new FileOutputStream(destLocalFile);
- byte[] buf = new byte[4096];
- int len;
- while ((len = stream.read(buf)) > 0) {
- Thread.yield();
- out.write(buf, 0, len);
- }
- out.close();
-
- destLocalFile.setReadable(true, false);
- destLocalFile.setExecutable(true, false);
- destLocalFile.setWritable(true);
-
- return true;
- } catch (Exception e) {
- Log.e(TAG, e.getMessage());
- } finally {
- if (stream != null) {
- try {
- stream.close();
- } catch (Exception e) {
- Log.e(TAG, e.getMessage());
- }
- }
- if (zipFile != null) {
- try {
- zipFile.close();
- } catch (Exception e) {
- Log.e(TAG, e.getMessage());
- }
- }
- }
- return false;
- }
-
- public static synchronized boolean initNativeLibs(Context context, String binaryName, File destLocalFile) {
-
- try {
- String folder = Build.CPU_ABI;
-
- String javaArch = System.getProperty("os.arch");
- if (javaArch != null && javaArch.contains("686")) {
- folder = "x86";
- }
-
- return loadFromZip(context, binaryName, destLocalFile, folder);
-
- } catch (Throwable e) {
- e.printStackTrace();
- }
-
- return false;
- }
-}
diff --git a/orbotOld/src/main/java/org/torproject/android/service/util/PortForwarder.java b/orbotOld/src/main/java/org/torproject/android/service/util/PortForwarder.java
deleted file mode 100644
index 26c3a3ff..00000000
--- a/orbotOld/src/main/java/org/torproject/android/service/util/PortForwarder.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package org.torproject.android.service.util;
-
-import android.util.Log;
-
-import com.offbynull.portmapper.PortMapperFactory;
-import com.offbynull.portmapper.gateway.Bus;
-import com.offbynull.portmapper.gateway.Gateway;
-import com.offbynull.portmapper.gateways.network.NetworkGateway;
-import com.offbynull.portmapper.gateways.network.internalmessages.KillNetworkRequest;
-import com.offbynull.portmapper.gateways.process.ProcessGateway;
-import com.offbynull.portmapper.gateways.process.internalmessages.KillProcessRequest;
-import com.offbynull.portmapper.mapper.MappedPort;
-import com.offbynull.portmapper.mapper.PortMapper;
-import com.offbynull.portmapper.mapper.PortType;
-
-import java.util.List;
-
-public class PortForwarder {
-
- private boolean shutdown = false;
- private Thread mThread = null;
-
- public void shutdown() {
- shutdown = true;
- }
-
- public void forward(final int internalPort, final int externalPort, final long lifetime) throws InterruptedException {
-
- mThread = new Thread() {
- public void run() {
- try {
- forwardSync(internalPort, externalPort, lifetime);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- };
-
- mThread.start();
- }
-
-
- public void forwardSync(int internalPort, int externalPort, long lifetime) throws InterruptedException {
- // Start gateways
- Gateway network = NetworkGateway.create();
- Gateway process = ProcessGateway.create();
- Bus networkBus = network.getBus();
- Bus processBus = process.getBus();
-
-// Discover port forwarding devices and take the first one found
- List mappers = PortMapperFactory.discover(networkBus, processBus);
- PortMapper mapper = mappers.get(0);
-
-// Map internal port 12345 to some external port (55555 preferred)
-//
-// IMPORTANT NOTE: Many devices prevent you from mapping ports that are <= 1024
-// (both internal and external ports). Be mindful of this when choosing which
-// ports you want to map.
- MappedPort mappedPort = mapper.mapPort(PortType.TCP, internalPort, externalPort, lifetime);
- Log.d(getClass().getName(), "Port mapping added: " + mappedPort);
-
-// Refresh mapping half-way through the lifetime of the mapping (for example,
-// if the mapping is available for 40 seconds, refresh it every 20 seconds)
- while (!shutdown) {
- mappedPort = mapper.refreshPort(mappedPort, mappedPort.getLifetime() / 2L);
- Log.d(getClass().getName(), "Port mapping refreshed: " + mappedPort);
- Thread.sleep(mappedPort.getLifetime() * 1000L);
- }
-
-// Unmap port 12345
- mapper.unmapPort(mappedPort);
-
-// Stop gateways
- networkBus.send(new KillNetworkRequest());
- processBus.send(new KillProcessRequest()); // can kill this after discovery
- }
-}
diff --git a/orbotOld/src/main/java/org/torproject/android/service/util/Prefs.java b/orbotOld/src/main/java/org/torproject/android/service/util/Prefs.java
deleted file mode 100644
index 1b2922a7..00000000
--- a/orbotOld/src/main/java/org/torproject/android/service/util/Prefs.java
+++ /dev/null
@@ -1,124 +0,0 @@
-package org.torproject.android.service.util;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-
-import org.torproject.android.service.OrbotConstants;
-
-import java.util.Locale;
-
-public class Prefs {
-
- private final static String PREF_BRIDGES_ENABLED = "pref_bridges_enabled";
- private final static String PREF_BRIDGES_LIST = "pref_bridges_list";
- private final static String PREF_DEFAULT_LOCALE = "pref_default_locale";
- private final static String PREF_ENABLE_LOGGING = "pref_enable_logging";
- private final static String PREF_EXPANDED_NOTIFICATIONS = "pref_expanded_notifications";
- private final static String PREF_PERSIST_NOTIFICATIONS = "pref_persistent_notifications";
- private final static String PREF_START_ON_BOOT = "pref_start_boot";
- private final static String PREF_ALLOW_BACKGROUND_STARTS = "pref_allow_background_starts";
- private final static String PREF_OPEN_PROXY_ON_ALL_INTERFACES = "pref_open_proxy_on_all_interfaces";
- private final static String PREF_USE_VPN = "pref_vpn";
- private final static String PREF_EXIT_NODES = "pref_exit_nodes";
- private final static String PREF_BE_A_SNOWFLAKE = "pref_be_a_snowflake";
-
- private static SharedPreferences prefs;
-
- public static void setContext(Context context) {
- if (prefs == null)
- prefs = getSharedPrefs(context);
- }
-
- private static void putBoolean(String key, boolean value) {
- prefs.edit().putBoolean(key, value).apply();
- }
-
- private static void putString(String key, String value) {
- prefs.edit().putString(key, value).apply();
- }
-
- public static boolean bridgesEnabled() {
- //if phone is in Farsi, enable bridges by default
- boolean bridgesEnabledDefault = Locale.getDefault().getLanguage().equals("fa");
- return prefs.getBoolean(PREF_BRIDGES_ENABLED, bridgesEnabledDefault);
- }
-
- public static void putBridgesEnabled(boolean value) {
- putBoolean(PREF_BRIDGES_ENABLED, value);
- }
-
- public static String getBridgesList() {
- String defaultBridgeType = "obfs4";
- if (Locale.getDefault().getLanguage().equals("fa"))
- defaultBridgeType = "meek"; //if Farsi, use meek as the default bridge type
- return prefs.getString(PREF_BRIDGES_LIST, defaultBridgeType);
- }
-
- public static void setBridgesList(String value) {
- putString(PREF_BRIDGES_LIST, value);
- }
-
- public static String getDefaultLocale() {
- return prefs.getString(PREF_DEFAULT_LOCALE, Locale.getDefault().getLanguage());
- }
-
- public static boolean beSnowflakeProxy () {
- return prefs.getBoolean(PREF_BE_A_SNOWFLAKE,false);
- }
-
- public static void setBeSnowflakeProxy (boolean beSnowflakeProxy) {
- putBoolean(PREF_BE_A_SNOWFLAKE,beSnowflakeProxy);
- }
-
- public static void setDefaultLocale(String value) {
- putString(PREF_DEFAULT_LOCALE, value);
- }
-
- public static boolean expandedNotifications() {
- return prefs.getBoolean(PREF_EXPANDED_NOTIFICATIONS, true);
- }
-
- public static boolean useDebugLogging() {
- return prefs.getBoolean(PREF_ENABLE_LOGGING, false);
- }
-
- public static boolean persistNotifications() {
- return prefs.getBoolean(PREF_PERSIST_NOTIFICATIONS, true);
- }
-
- public static boolean allowBackgroundStarts() {
- return prefs.getBoolean(PREF_ALLOW_BACKGROUND_STARTS, true);
- }
-
- public static boolean openProxyOnAllInterfaces() {
- return prefs.getBoolean(PREF_OPEN_PROXY_ON_ALL_INTERFACES, false);
- }
-
- public static boolean useVpn() {
- return prefs.getBoolean(PREF_USE_VPN, false);
- }
-
- public static void putUseVpn(boolean value) {
- putBoolean(PREF_USE_VPN, value);
- }
-
- public static boolean startOnBoot() {
- return prefs.getBoolean(PREF_START_ON_BOOT, true);
- }
-
- public static void putStartOnBoot(boolean value) {
- putBoolean(PREF_START_ON_BOOT, value);
- }
-
- public static String getExitNodes() {
- return prefs.getString(PREF_EXIT_NODES, "");
- }
-
- public static void setExitNodes(String exits) {
- putString(PREF_EXIT_NODES, exits);
- }
-
- public static SharedPreferences getSharedPrefs(Context context) {
- return context.getSharedPreferences(OrbotConstants.PREF_TOR_SHARED_PREFS, Context.MODE_MULTI_PROCESS);
- }
-}
diff --git a/orbotOld/src/main/java/org/torproject/android/service/util/TCPSourceApp.java b/orbotOld/src/main/java/org/torproject/android/service/util/TCPSourceApp.java
deleted file mode 100644
index cb61a9c7..00000000
--- a/orbotOld/src/main/java/org/torproject/android/service/util/TCPSourceApp.java
+++ /dev/null
@@ -1,307 +0,0 @@
-package org.torproject.android.service.util;
-
-/***********************************************************************
- *
- * Copyright (c) 2013, Sebastiano Gottardo
- * All rights reserved.
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the MegaDevs nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL SEBASTIANO GOTTARDO BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.SocketException;
-import java.util.Collections;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Main class for the TCPSourceApp library.
- *
- * @author Sebastiano Gottardo
- */
-public class TCPSourceApp {
-
- /*
- * In a Linux-based OS, each active TCP socket is mapped in the following
- * two files. A socket may be mapped in the '/proc/net/tcp' file in case
- * of a simple IPv4 address, or in the '/proc/net/tcp6' if an IPv6 address
- * is available.
- */
- private static final String TCP_4_FILE_PATH = "/proc/net/tcp";
- private static final String TCP_6_FILE_PATH = "/proc/net/tcp6";
- /*
- * Two regular expressions that are able to extract valuable informations
- * from the two /proc/net/tcp* files. More specifically, there are three
- * fields that are extracted:
- * - address
- * - port
- * - PID
- */
- private static final String TCP_6_PATTERN = "\\d+:\\s([0-9A-F]{32}):([0-9A-F]{4})\\s[0-9A-F]{32}:[0-9A-F]{4}\\s[0-9A-F]{2}\\s[0-9]{8}:[0-9]{8}\\s[0-9]{2}:[0-9]{8}\\s[0-9]{8}\\s+([0-9]+)";
- private static final String TCP_4_PATTERN = "\\d+:\\s([0-9A-F]{8}):([0-9A-F]{4})\\s[0-9A-F]{8}:[0-9A-F]{4}\\s[0-9A-F]{2}\\s[0-9A-F]{8}:[0-9A-F]{8}\\s[0-9]{2}:[0-9]{8}\\s[0-9A-F]{8}\\s+([0-9]+)";
-//sargo:/ $ cat /proc/net/tcp6
-// sl local_address remote_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
-// 0: 00000000000000000000000000000000:C36A 00000000000000000000000000000000:0000 8A 00000000:00000000 00:00000000 00000000 1001 0 35059 1 0000000000000000 99 0 0 10 0
-// 1: 00000000000000000000000000000000:A64B 00000000000000000000000000000000:0000 8A 00000000:00000000 00:00000000 00000000 1001 0 910009 1 0000000000000000 99 0 0 10 0
- /*
- * Optimises the socket lookup by checking if the connected network
- * interface has a 'valid' IPv6 address (a global address, not a link-local
- * one).
- */
- private static boolean checkConnectedIfaces = true;
-// sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
-// 0: 00000000:C368 00000000:0000 8A 00000000:00000000 00:00000000 00000000 1001 0 34999 1 0000000000000000 99 0 0 10 0
-
- /**
- * The main method of the TCPSourceApp library. This method receives an
- * Android Context instance, which is used to access the PackageManager.
- * It parses the /proc/net/tcp* files, looking for a socket entry that
- * matches the given port. If it finds an entry, this method extracts the
- * PID value and it uses the PackageManager.getPackagesFromPid() method to
- * find the originating application.
- *
- * @param context a valid Android Context instance
- * @param daddr the (logical) address of the destination
- * @param dport the (logical) port of the destination
- * @return an AppDescriptor object, representing the found application; null
- * if no application could be found
- */
- public static AppDescriptor getApplicationInfo(Context context, String saddr, int sport, String daddr, int dport) {
-
- File tcp;
- BufferedReader reader;
- String line;
- StringBuilder builder;
- String content;
-
- try {
- boolean hasIPv6 = true;
-
- // if true, checks for a connected network interface with a valid
- // IPv4 / IPv6 address
- if (checkConnectedIfaces) {
- String ipv4Address = getIPAddress(true);
- String ipv6Address = getIPAddress(false);
-
- hasIPv6 = (ipv6Address.length() > 0);
- }
-
- tcp = new File(TCP_6_FILE_PATH);
- reader = new BufferedReader(new FileReader(tcp));
- builder = new StringBuilder();
-
- while ((line = reader.readLine()) != null) {
- builder.append(line);
- }
-
- content = builder.toString();
-
- Matcher m6 = Pattern.compile(TCP_6_PATTERN, Pattern.CASE_INSENSITIVE | Pattern.UNIX_LINES | Pattern.DOTALL).matcher(content);
-
- if (hasIPv6)
- while (m6.find()) {
- String addressEntry = m6.group(1);
- String portEntry = m6.group(2);
- int pidEntry = Integer.valueOf(m6.group(3));
-
- if (Integer.parseInt(portEntry, 16) == dport) {
- PackageManager manager = context.getPackageManager();
- String[] packagesForUid = manager.getPackagesForUid(pidEntry);
-
- if (packagesForUid != null) {
- String packageName = packagesForUid[0];
- PackageInfo pInfo = manager.getPackageInfo(packageName, 0);
- String version = pInfo.versionName;
-
- return new AppDescriptor(pidEntry, packageName, version);
- }
- }
- }
-
- } catch (SocketException e) {
- e.printStackTrace();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (NameNotFoundException e) {
- e.printStackTrace();
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- // From here, no connection with the given port could be found in the tcp6 file
- // So let's try the tcp (IPv4) one
-
- try {
- tcp = new File(TCP_4_FILE_PATH);
- reader = new BufferedReader(new FileReader(tcp));
- builder = new StringBuilder();
-
- while ((line = reader.readLine()) != null) {
- builder.append(line);
- }
-
- content = builder.toString();
-
- Matcher m4 = Pattern.compile(TCP_4_PATTERN, Pattern.CASE_INSENSITIVE | Pattern.UNIX_LINES | Pattern.DOTALL).matcher(content);
-
- while (m4.find()) {
- String addressEntry = m4.group(1);
- String portEntry = m4.group(2);
- int pidEntry = Integer.valueOf(m4.group(3));
-
- if (Integer.parseInt(portEntry, 16) == dport) {
- PackageManager manager = context.getPackageManager();
- String[] packagesForUid = manager.getPackagesForUid(pidEntry);
-
- if (packagesForUid != null) {
- String packageName = packagesForUid[0];
- PackageInfo pInfo = manager.getPackageInfo(packageName, 0);
- String version = pInfo.versionName;
-
- return new AppDescriptor(pidEntry, packageName, version);
- }
- }
- }
-
- } catch (SocketException e) {
- e.printStackTrace();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (NameNotFoundException e) {
- e.printStackTrace();
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- return null;
- }
-
- @SuppressLint("DefaultLocale")
- public static String getIPAddress(boolean useIPv4) throws SocketException {
-
- List interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
-
- for (NetworkInterface intf : interfaces) {
- List addrs = Collections.list(intf.getInetAddresses());
-
- for (InetAddress addr : addrs) {
- if (!addr.isLoopbackAddress()) {
- String sAddr = addr.getHostAddress().toUpperCase();
-
- boolean isIPv4 = addr instanceof Inet4Address;
-
- if (useIPv4) {
- if (isIPv4)
- return sAddr;
- } else {
- if (!isIPv4) {
- if (sAddr.startsWith("fe80") || sAddr.startsWith("FE80")) // skipping link-local addresses
- continue;
-
- int delim = sAddr.indexOf('%'); // drop ip6 port suffix
- return delim < 0 ? sAddr : sAddr.substring(0, delim);
- }
- }
- }
- }
- }
-
- return "";
- }
-
- /*
- * Sets the connected interfaces optimisation.
- */
- public static void setCheckConnectedIfaces(boolean value) {
- checkConnectedIfaces = value;
- }
-
- /*
- * This class represents an Android application. Each application is
- * uniquely identified by its package name (e.g. com.megadevs.tcpsourceapp)
- * and its version (e.g. 1.0).
- */
- public static class AppDescriptor {
-
- private String packageName;
- private String version;
- private int uid;
-
- public AppDescriptor(int uid, String pName, String ver) {
- this.uid = uid;
- packageName = pName;
- version = ver;
- }
-
- public int getUid() {
- return uid;
- }
-
- public String getPackageName() {
- return packageName;
- }
-
- public String getVersion() {
- return version;
- }
-
- /*
- * Override of the 'equals' method, in order to have a proper
- * comparison between two AppDescriptor objects.
- *
- * (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object o) {
-
- if (o instanceof AppDescriptor) {
- boolean c1 = ((AppDescriptor) o).packageName.compareTo(this.packageName) == 0;
- boolean c2 = ((AppDescriptor) o).version.compareTo(this.version) == 0;
-
- return c1 && c2;
- }
-
- return false;
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/orbotOld/src/main/java/org/torproject/android/service/util/TorServiceUtils.java b/orbotOld/src/main/java/org/torproject/android/service/util/TorServiceUtils.java
deleted file mode 100644
index ebc829a0..00000000
--- a/orbotOld/src/main/java/org/torproject/android/service/util/TorServiceUtils.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (c) 2009, Nathan Freitas, Orbot / The Guardian Project - http://openideals.com/guardian */
-/* See LICENSE for licensing information */
-package org.torproject.android.service.util;
-
-import org.torproject.android.service.TorServiceConstants;
-
-import java.net.ConnectException;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-
-public class TorServiceUtils implements TorServiceConstants {
-
- public static boolean isPortOpen(final String ip, final int port, final int timeout) {
- try {
- Socket socket = new Socket();
- socket.connect(new InetSocketAddress(ip, port), timeout);
- socket.close();
- return true;
- } catch (ConnectException ce) {
- //ce.printStackTrace();
- return false;
- } catch (Exception ex) {
- //ex.printStackTrace();
- return false;
- }
- }
-}
diff --git a/orbotOld/src/main/java/org/torproject/android/service/util/Utils.java b/orbotOld/src/main/java/org/torproject/android/service/util/Utils.java
deleted file mode 100644
index 2cb34389..00000000
--- a/orbotOld/src/main/java/org/torproject/android/service/util/Utils.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/* Copyright (c) 2009, Nathan Freitas, Orbot / The Guardian Project - http://openideals.com/guardian */
-/* See LICENSE for licensing information */
-
-
-package org.torproject.android.service.util;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-public class Utils {
-
-
- public static String readString(InputStream stream) {
- String line;
-
- StringBuffer out = new StringBuffer();
-
- try {
- BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
-
- while ((line = reader.readLine()) != null) {
- out.append(line);
- out.append('\n');
-
- }
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return out.toString();
-
- }
-
- /*
- * Load the log file text
- */
- public static String loadTextFile(String path) {
- String line;
-
- StringBuffer out = new StringBuffer();
-
- try {
- BufferedReader reader = new BufferedReader((new FileReader(new File(path))));
-
- while ((line = reader.readLine()) != null) {
- out.append(line);
- out.append('\n');
-
- }
-
- reader.close();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return out.toString();
-
- }
-
-
- /*
- * Load the log file text
- */
- public static boolean saveTextFile(String path, String contents) {
-
- try {
-
- FileWriter writer = new FileWriter(path, false);
- writer.write(contents);
-
- writer.close();
-
-
- return true;
-
- } catch (IOException e) {
- // Log.d(TAG, "error writing file: " + path, e);
- e.printStackTrace();
- return false;
- }
-
-
- }
-
-
- /*
- *
- * Zips a file at a location and places the resulting zip file at the toLocation
- * Example: zipFileAtPath("downloads/myfolder", "downloads/myFolder.zip");
- */
-
- public static boolean zipFileAtPath(String sourcePath, String toLocation) {
- final int BUFFER = 2048;
-
- File sourceFile = new File(sourcePath);
- try {
- BufferedInputStream origin;
- FileOutputStream dest = new FileOutputStream(toLocation);
- ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(
- dest));
- if (sourceFile.isDirectory()) {
- zipSubFolder(out, sourceFile, sourceFile.getParent().length());
- } else {
- byte[] data = new byte[BUFFER];
- FileInputStream fi = new FileInputStream(sourcePath);
- origin = new BufferedInputStream(fi, BUFFER);
- ZipEntry entry = new ZipEntry(getLastPathComponent(sourcePath));
- entry.setTime(sourceFile.lastModified()); // to keep modification time after unzipping
- out.putNextEntry(entry);
- int count;
- while ((count = origin.read(data, 0, BUFFER)) != -1) {
- out.write(data, 0, count);
- }
- }
- out.close();
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- return true;
- }
-
- /*
- *
- * Zips a subfolder
- *
- */
-
- private static void zipSubFolder(ZipOutputStream out, File folder,
- int basePathLength) throws IOException {
-
- final int BUFFER = 2048;
-
- File[] fileList = folder.listFiles();
- BufferedInputStream origin;
- for (File file : fileList) {
- if (file.isDirectory()) {
- zipSubFolder(out, file, basePathLength);
- } else {
- byte[] data = new byte[BUFFER];
- String unmodifiedFilePath = file.getPath();
- String relativePath = unmodifiedFilePath
- .substring(basePathLength);
- FileInputStream fi = new FileInputStream(unmodifiedFilePath);
- origin = new BufferedInputStream(fi, BUFFER);
- ZipEntry entry = new ZipEntry(relativePath);
- entry.setTime(file.lastModified()); // to keep modification time after unzipping
- out.putNextEntry(entry);
- int count;
- while ((count = origin.read(data, 0, BUFFER)) != -1) {
- out.write(data, 0, count);
- }
- origin.close();
- }
- }
- }
-
- /*
- * gets the last path component
- *
- * Example: getLastPathComponent("downloads/example/fileToZip");
- * Result: "fileToZip"
- */
- public static String getLastPathComponent(String filePath) {
- String[] segments = filePath.split("/");
- if (segments.length == 0)
- return "";
- return segments[segments.length - 1];
- }
-}
diff --git a/orbotOld/src/main/java/org/torproject/android/service/vpn/OrbotVpnManager.java b/orbotOld/src/main/java/org/torproject/android/service/vpn/OrbotVpnManager.java
deleted file mode 100644
index 66538b04..00000000
--- a/orbotOld/src/main/java/org/torproject/android/service/vpn/OrbotVpnManager.java
+++ /dev/null
@@ -1,408 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.torproject.android.service.vpn;
-
-import android.annotation.TargetApi;
-import android.app.Service;
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.net.VpnService;
-import android.os.Build;
-import android.os.Handler;
-import android.os.Message;
-import android.os.ParcelFileDescriptor;
-import android.text.TextUtils;
-import android.util.Log;
-import android.widget.Toast;
-
-import com.runjva.sourceforge.jsocks.protocol.ProxyServer;
-import com.runjva.sourceforge.jsocks.server.ServerAuthenticatorNone;
-
-import org.torproject.android.service.OrbotConstants;
-import org.torproject.android.service.OrbotService;
-import org.torproject.android.service.R;
-import org.torproject.android.service.TorServiceConstants;
-import org.torproject.android.service.util.CustomNativeLoader;
-import org.torproject.android.service.util.Prefs;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.concurrent.TimeoutException;
-
-import static org.torproject.android.service.TorServiceConstants.ACTION_START;
-import static org.torproject.android.service.TorServiceConstants.ACTION_START_VPN;
-import static org.torproject.android.service.TorServiceConstants.ACTION_STOP_VPN;
-
-public class OrbotVpnManager implements Handler.Callback {
- private static final String TAG = "OrbotVpnService";
- private final static int VPN_MTU = 1500;
- private final static boolean mIsLollipop = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
- private final static String PDNSD_BIN = "pdnsd";
- public static int sSocksProxyServerPort = -1;
- public static String sSocksProxyLocalhost = null;
- boolean isStarted = false;
- File filePdnsPid;
- private Thread mThreadVPN;
- private final static String mSessionName = "OrbotVPN";
- private ParcelFileDescriptor mInterface;
- private int mTorSocks = -1;
- private int mTorDns = -1;
- private int pdnsdPort = 8091;
- private ProxyServer mSocksProxyServer;
- private final File filePdnsd;
- private boolean isRestart = false;
- private final VpnService mService;
-
- public OrbotVpnManager(VpnService service) {
- mService = service;
- filePdnsd = CustomNativeLoader.loadNativeBinary(service.getApplicationContext(), PDNSD_BIN, new File(service.getFilesDir(), PDNSD_BIN));
- Tun2Socks.init();
- }
-
- public static File makePdnsdConf(Context context, File fileDir, String torDnsHost, int torDnsPort, String pdnsdHost, int pdnsdPort) throws IOException {
- String conf = String.format(context.getString(R.string.pdnsd_conf), torDnsHost, torDnsPort, fileDir.getCanonicalPath(), pdnsdHost, pdnsdPort);
-
- Log.d(TAG, "pdsnd conf:" + conf);
-
- File fPid = new File(fileDir, pdnsdPort + "pdnsd.conf");
-
- if (fPid.exists()) {
- fPid.delete();
- }
-
- FileOutputStream fos = new FileOutputStream(fPid, false);
- PrintStream ps = new PrintStream(fos);
- ps.print(conf);
- ps.close();
-
- File cache = new File(fileDir, "pdnsd.cache");
-
- if (!cache.exists()) {
- try {
- cache.createNewFile();
- } catch (Exception e) {
- }
- }
- return fPid;
- }
-
- public int handleIntent(VpnService.Builder builder, Intent intent) {
- if (intent != null) {
- String action = intent.getAction();
-
- if (action != null) {
- if (action.equals(ACTION_START_VPN) || action.equals(ACTION_START)) {
- Log.d(TAG, "starting VPN");
-
- isStarted = true;
-
- // Stop the previous session by interrupting the thread.
- if (mThreadVPN != null && mThreadVPN.isAlive())
- stopVPN();
-
- if (mTorSocks != -1) {
- if (!mIsLollipop) {
- startSocksBypass();
- }
-
- setupTun2Socks(builder);
- }
-
- } else if (action.equals(ACTION_STOP_VPN)) {
- isStarted = false;
-
- Log.d(TAG, "stopping VPN");
-
- stopVPN();
- } else if (action.equals(TorServiceConstants.LOCAL_ACTION_PORTS)) {
- Log.d(TAG, "setting VPN ports");
-
- int torSocks = intent.getIntExtra(OrbotService.EXTRA_SOCKS_PROXY_PORT, -1);
- int torDns = intent.getIntExtra(OrbotService.EXTRA_DNS_PORT, -1);
-
- //if running, we need to restart
- if ((torSocks != mTorSocks || torDns != mTorDns)) {
-
- mTorSocks = torSocks;
- mTorDns = torDns;
-
- if (!mIsLollipop) {
- stopSocksBypass();
- startSocksBypass();
- }
-
- setupTun2Socks(builder);
- }
- }
- }
-
- }
-
-
- return Service.START_STICKY;
- }
-
- private void startSocksBypass() {
- new Thread() {
- public void run() {
-
- //generate the proxy port that the
- if (sSocksProxyServerPort == -1) {
- try {
-
- sSocksProxyLocalhost = "127.0.0.1";// InetAddress.getLocalHost().getHostAddress();
- sSocksProxyServerPort = (int) ((Math.random() * 1000) + 10000);
-
- } catch (Exception e) {
- Log.e(TAG, "Unable to access localhost", e);
- throw new RuntimeException("Unable to access localhost: " + e);
-
- }
-
- }
-
-
- if (mSocksProxyServer != null) {
- stopSocksBypass();
- }
-
- try {
- mSocksProxyServer = new ProxyServer(new ServerAuthenticatorNone(null, null));
- ProxyServer.setVpnService(mService);
- mSocksProxyServer.start(sSocksProxyServerPort, 5, InetAddress.getLocalHost());
-
- } catch (Exception e) {
- Log.e(TAG, "error getting host", e);
- }
- }
- }.start();
- }
-
- private synchronized void stopSocksBypass() {
- if (mSocksProxyServer != null) {
- mSocksProxyServer.stop();
- mSocksProxyServer = null;
- }
- }
-
- private void stopVPN() {
- if (mIsLollipop)
- stopSocksBypass();
-
- Tun2Socks.Stop();
-
- if (mInterface != null) {
- try {
- Log.d(TAG, "closing interface, destroying VPN interface");
-
- mInterface.close();
- mInterface = null;
-
- } catch (Exception e) {
- Log.d(TAG, "error stopping tun2socks", e);
- } catch (Error e) {
- Log.d(TAG, "error stopping tun2socks", e);
- }
- }
- stopDns();
- mThreadVPN = null;
- }
-
- @Override
- public boolean handleMessage(Message message) {
- if (message != null) {
- Toast.makeText(mService, message.what, Toast.LENGTH_SHORT).show();
- }
- return true;
- }
-
- private synchronized void setupTun2Socks(final VpnService.Builder builder) {
- if (mInterface != null) //stop tun2socks now to give it time to clean up
- {
- isRestart = true;
- Tun2Socks.Stop();
-
- stopDns();
-
- }
-
- mThreadVPN = new Thread() {
-
- public void run() {
- try {
-
- if (isRestart) {
- Log.d(TAG, "is a restart... let's wait for a few seconds");
- Thread.sleep(3000);
- }
-
- final String vpnName = "OrbotVPN";
- final String localhost = "127.0.0.1";
-
- final String virtualGateway = "192.168.200.1";
- final String virtualIP = "192.168.200.2";
- final String virtualNetMask = "255.255.255.0";
- final String dummyDNS = "1.1.1.1"; //this is intercepted by the tun2socks library, but we must put in a valid DNS to start
- final String defaultRoute = "0.0.0.0";
-
- final String localSocks = localhost + ':' + mTorSocks;
-
- builder.setMtu(VPN_MTU);
- builder.addAddress(virtualGateway, 32);
-
- builder.setSession(vpnName);
-
- //route all traffic through VPN (we might offer country specific exclude lists in the future)
- builder.addRoute(defaultRoute, 0);
-
- builder.addDnsServer(dummyDNS);
- builder.addRoute(dummyDNS, 32);
-
- //handle ipv6
- //builder.addAddress("fdfe:dcba:9876::1", 126);
- //builder.addRoute("::", 0);
-
- if (mIsLollipop)
- doLollipopAppRouting(builder);
-
- // https://developer.android.com/reference/android/net/VpnService.Builder#setMetered(boolean)
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
- builder.setMetered(false);
- }
-
- // Create a new interface using the builder and save the parameters.
- ParcelFileDescriptor newInterface = builder.setSession(mSessionName)
- .setConfigureIntent(null) // previously this was set to a null member variable
- .establish();
-
- if (mInterface != null) {
- Log.d(TAG, "Stopping existing VPN interface");
- mInterface.close();
- mInterface = null;
- }
-
- mInterface = newInterface;
-
- isRestart = false;
-
- //start PDNSD daemon pointing to actual DNS
- if (filePdnsd != null) {
-
- pdnsdPort++;
- startDNS(filePdnsd.getCanonicalPath(), localhost, mTorDns, virtualGateway, pdnsdPort);
- final boolean localDnsTransparentProxy = true;
-
- Tun2Socks.Start(mService, mInterface, VPN_MTU, virtualIP, virtualNetMask, localSocks, virtualGateway + ":" + pdnsdPort, localDnsTransparentProxy);
- }
-
- } catch (Exception e) {
- Log.d(TAG, "tun2Socks has stopped", e);
- }
- }
-
- };
-
- mThreadVPN.start();
-
- }
-
- @TargetApi(Build.VERSION_CODES.LOLLIPOP)
- private void doLollipopAppRouting(VpnService.Builder builder) throws NameNotFoundException {
- SharedPreferences prefs = Prefs.getSharedPrefs(mService.getApplicationContext());
- ArrayList apps = TorifiedApp.getApps(mService, prefs);
-
-
- boolean perAppEnabled = false;
-
- for (TorifiedApp app : apps) {
- if (app.isTorified() && (!app.getPackageName().equals(mService.getPackageName()))) {
- if (prefs.getBoolean(app.getPackageName() + OrbotConstants.APP_TOR_KEY, true)) {
-
- builder.addAllowedApplication(app.getPackageName());
-
- }
-
- perAppEnabled = true;
-
- }
- }
-
- if (!perAppEnabled)
- builder.addDisallowedApplication(mService.getPackageName());
-
- }
-
- private void startDNS(String pdnsPath, String torDnsHost, int torDnsPort, String pdnsdHost, int pdnsdPort) throws IOException, TimeoutException {
-
- File fileConf = makePdnsdConf(mService, mService.getFilesDir(), torDnsHost, torDnsPort, pdnsdHost, pdnsdPort);
-
- String[] cmdString = {pdnsPath, "-c", fileConf.toString(), "-g", "-v2"};
- ProcessBuilder pb = new ProcessBuilder(cmdString);
- pb.redirectErrorStream(true);
- Process proc = pb.start();
- try {
- proc.waitFor();
- } catch (Exception e) {
- }
-
- Log.i(TAG, "PDNSD: " + proc.exitValue());
-
- if (proc.exitValue() != 0) {
- BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInputStream()));
-
- String line;
- while ((line = br.readLine()) != null) {
- Log.d(TAG, "pdnsd: " + line);
- }
- }
-
-
- }
-
- private void stopDns() {
- if (filePdnsPid != null && filePdnsPid.exists()) {
- ArrayList lines = new ArrayList<>();
- try {
- BufferedReader reader = new BufferedReader(new FileReader(filePdnsPid));
-
- String line = null;
- while ((line = reader.readLine())!= null)
- lines.add(line);
-
- String dnsPid = lines.get(0);
- VpnUtils.killProcess(dnsPid, "");
- filePdnsPid.delete();
- filePdnsPid = null;
- } catch (Exception e) {
- Log.e("OrbotVPN", "error killing dns process", e);
- }
- }
- }
-
- public boolean isStarted() {
- return isStarted;
- }
-}
diff --git a/orbotOld/src/main/java/org/torproject/android/service/vpn/TorifiedApp.java b/orbotOld/src/main/java/org/torproject/android/service/vpn/TorifiedApp.java
deleted file mode 100644
index b7bc01e6..00000000
--- a/orbotOld/src/main/java/org/torproject/android/service/vpn/TorifiedApp.java
+++ /dev/null
@@ -1,260 +0,0 @@
-package org.torproject.android.service.vpn;
-
-import android.Manifest;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.graphics.drawable.Drawable;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import static org.torproject.android.service.vpn.VpnPrefs.PREFS_KEY_TORIFIED;
-
-public class TorifiedApp implements Comparable {
-
- private boolean enabled;
- private int uid;
- private String username;
- private String procname;
- private String name;
- private Drawable icon;
- private String packageName;
-
- private boolean torified = false;
- private boolean usesInternet = false;
- private int[] enabledPorts;
-
- public static ArrayList getApps(Context context, SharedPreferences prefs) {
-
- String tordAppString = prefs.getString(PREFS_KEY_TORIFIED, "");
- String[] tordApps;
-
- StringTokenizer st = new StringTokenizer(tordAppString, "|");
- tordApps = new String[st.countTokens()];
- int tordIdx = 0;
- while (st.hasMoreTokens()) {
- tordApps[tordIdx++] = st.nextToken();
- }
-
- Arrays.sort(tordApps);
-
- //else load the apps up
- PackageManager pMgr = context.getPackageManager();
-
- List lAppInfo = pMgr.getInstalledApplications(0);
-
- Iterator itAppInfo = lAppInfo.iterator();
-
- ArrayList apps = new ArrayList<>();
-
- ApplicationInfo aInfo;
-
- int appIdx = 0;
- TorifiedApp app;
-
- while (itAppInfo.hasNext()) {
- aInfo = itAppInfo.next();
-
- app = new TorifiedApp();
-
- try {
- PackageInfo pInfo = pMgr.getPackageInfo(aInfo.packageName, PackageManager.GET_PERMISSIONS);
-
- if (pInfo != null && pInfo.requestedPermissions != null) {
- for (String permInfo : pInfo.requestedPermissions) {
- if (permInfo.equals(Manifest.permission.INTERNET)) {
- app.setUsesInternet(true);
-
- }
- }
-
- }
-
-
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- if ((aInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
- //System app
- app.setUsesInternet(true);
- }
-
-
- if (!app.usesInternet())
- continue;
- else {
- apps.add(app);
- }
-
-
- app.setEnabled(aInfo.enabled);
- app.setUid(aInfo.uid);
- app.setUsername(pMgr.getNameForUid(app.getUid()));
- app.setProcname(aInfo.processName);
- app.setPackageName(aInfo.packageName);
-
- try {
- app.setName(pMgr.getApplicationLabel(aInfo).toString());
- } catch (Exception e) {
- app.setName(aInfo.packageName);
- }
-
-
- //app.setIcon(pMgr.getApplicationIcon(aInfo));
-
- // check if this application is allowed
- if (Arrays.binarySearch(tordApps, app.getUsername()) >= 0) {
- app.setTorified(true);
- } else {
- app.setTorified(false);
- }
-
- appIdx++;
- }
-
- Collections.sort(apps);
-
- return apps;
- }
-
- public boolean usesInternet() {
- return usesInternet;
- }
-
- public void setUsesInternet(boolean usesInternet) {
- this.usesInternet = usesInternet;
- }
-
- /**
- * @return the torified
- */
- public boolean isTorified() {
- return torified;
- }
-
- /**
- * @param torified the torified to set
- */
- public void setTorified(boolean torified) {
- this.torified = torified;
- }
-
- /**
- * @return the enabledPorts
- */
- public int[] getEnabledPorts() {
- return enabledPorts;
- }
-
- /**
- * @param enabledPorts the enabledPorts to set
- */
- public void setEnabledPorts(int[] enabledPorts) {
- this.enabledPorts = enabledPorts;
- }
-
- /**
- * @return the enabled
- */
- public boolean isEnabled() {
- return enabled;
- }
-
- /**
- * @param enabled the enabled to set
- */
- public void setEnabled(boolean enabled) {
- this.enabled = enabled;
- }
-
- /**
- * @return the uid
- */
- public int getUid() {
- return uid;
- }
-
- /**
- * @param uid the uid to set
- */
- public void setUid(int uid) {
- this.uid = uid;
- }
-
- /**
- * @return the username
- */
- public String getUsername() {
- return username;
- }
-
- /**
- * @param username the username to set
- */
- public void setUsername(String username) {
- this.username = username;
- }
-
- /**
- * @return the procname
- */
- public String getProcname() {
- return procname;
- }
-
- /**
- * @param procname the procname to set
- */
- public void setProcname(String procname) {
- this.procname = procname;
- }
-
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
- public Drawable getIcon() {
- return icon;
- }
-
- public void setIcon(Drawable icon) {
- this.icon = icon;
- }
-
- @Override
- public int compareTo(Object another) {
- return this.toString().compareToIgnoreCase(another.toString());
- }
-
- @Override
- public String toString() {
- return getName();
- }
-
- public String getPackageName() {
- return packageName;
- }
-
- public void setPackageName(String packageName) {
- this.packageName = packageName;
- }
-}
diff --git a/orbotOld/src/main/java/org/torproject/android/service/vpn/Tun2Socks.java b/orbotOld/src/main/java/org/torproject/android/service/vpn/Tun2Socks.java
deleted file mode 100644
index 461a5a8d..00000000
--- a/orbotOld/src/main/java/org/torproject/android/service/vpn/Tun2Socks.java
+++ /dev/null
@@ -1,173 +0,0 @@
-package org.torproject.android.service.vpn;
-
-/*
- * Copyright (c) 2013, Psiphon Inc.
- * All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.net.ConnectivityManager;
-import android.os.Build;
-import android.os.ParcelFileDescriptor;
-import android.util.Log;
-
-import org.torproject.android.service.util.TCPSourceApp;
-
-import java.net.DatagramSocket;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.util.HashMap;
-
-import static android.content.Context.CONNECTIVITY_SERVICE;
-
-public class Tun2Socks {
-
- private static final String TAG = Tun2Socks.class.getSimpleName();
- private static final boolean LOGD = true;
-
- private static ParcelFileDescriptor mVpnInterfaceFileDescriptor;
- private static int mVpnInterfaceMTU;
- private static String mVpnIpAddress;
- private static String mVpnNetMask;
- private static String mSocksServerAddress;
- private static String mUdpgwServerAddress;
- private static boolean mUdpgwTransparentDNS;
- private static HashMap mAppUidBlacklist = new HashMap<>();
-
- static {
- System.loadLibrary("tun2socks");
- }
-
- public static void init() {
- }
- // Note: this class isn't a singleton, but you can't run more
- // than one instance due to the use of global state (the lwip
- // module, etc.) in the native code.
-
- public static void Start(
- Context context,
- ParcelFileDescriptor vpnInterfaceFileDescriptor,
- int vpnInterfaceMTU,
- String vpnIpAddress,
- String vpnNetMask,
- String socksServerAddress,
- String udpgwServerAddress,
- boolean udpgwTransparentDNS) {
-
- mVpnInterfaceFileDescriptor = vpnInterfaceFileDescriptor;
- mVpnInterfaceMTU = vpnInterfaceMTU;
- mVpnIpAddress = vpnIpAddress;
- mVpnNetMask = vpnNetMask;
- mSocksServerAddress = socksServerAddress;
- mUdpgwServerAddress = udpgwServerAddress;
- mUdpgwTransparentDNS = udpgwTransparentDNS;
-
- if (mVpnInterfaceFileDescriptor != null)
- runTun2Socks(
- mVpnInterfaceFileDescriptor.detachFd(),
- mVpnInterfaceMTU,
- mVpnIpAddress,
- mVpnNetMask,
- mSocksServerAddress,
- mUdpgwServerAddress,
- mUdpgwTransparentDNS ? 1 : 0);
- }
-
- public static void Stop() {
-
- terminateTun2Socks();
-
- }
-
- public static void logTun2Socks(
- String level,
- String channel,
- String msg) {
- String logMsg = level + "(" + channel + "): " + msg;
- if (0 == level.compareTo("ERROR")) {
- Log.e(TAG, logMsg);
- } else {
- if (LOGD) Log.d(TAG, logMsg);
- }
- }
-
- private native static int runTun2Socks(
- int vpnInterfaceFileDescriptor,
- int vpnInterfaceMTU,
- String vpnIpAddress,
- String vpnNetMask,
- String socksServerAddress,
- String udpgwServerAddress,
- int udpgwTransparentDNS);
-
- private native static void terminateTun2Socks();
-
- public static boolean checkIsAllowed(Context context, int protocol, String sourceAddr, int sourcePort, String destAddr, int destPort) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
- return isAllowedQ(context, protocol, sourceAddr, sourcePort, destAddr, destPort);
- } else
- return isAllowed(context, protocol, sourceAddr, sourcePort, destAddr, destPort);
- }
-
- public static boolean isAllowed(Context context, int protocol, String sourceAddr, int sourcePort, String destAddr, int destPort) {
-
- TCPSourceApp.AppDescriptor aInfo = TCPSourceApp.getApplicationInfo(context, sourceAddr, sourcePort, destAddr, destPort);
-
- if (aInfo != null) {
- int uid = aInfo.getUid();
- return mAppUidBlacklist.containsKey(uid);
- } else
- return true;
- }
-
- @TargetApi(Build.VERSION_CODES.Q)
- public static boolean isAllowedQ(Context context, int protocol, String sourceAddr, int sourcePort, String destAddr, int destPort) {
- ConnectivityManager cm = (ConnectivityManager) context.getSystemService(CONNECTIVITY_SERVICE);
- if (cm == null)
- return false;
-
- InetSocketAddress local = new InetSocketAddress(sourceAddr, sourcePort);
- InetSocketAddress remote = new InetSocketAddress(destAddr, destPort);
-
- int uid = cm.getConnectionOwnerUid(protocol, local, remote);
- return mAppUidBlacklist.containsKey(uid);
- }
-
- public static void setBlacklist(HashMap appUidBlacklist) {
- mAppUidBlacklist = appUidBlacklist;
- }
-
- public static void clearBlacklist() {
- mAppUidBlacklist.clear();
- }
-
- public static void addToBlacklist(int uid, String pkgId) {
- mAppUidBlacklist.put(uid, pkgId);
- }
-
- public static void removeFromBlacklist(int uid) {
- mAppUidBlacklist.remove(uid);
- }
-
- public interface IProtectSocket {
- boolean doVpnProtect(Socket socket);
-
- boolean doVpnProtect(DatagramSocket socket);
- }
-
-}
\ No newline at end of file
diff --git a/orbotOld/src/main/java/org/torproject/android/service/vpn/VpnPrefs.java b/orbotOld/src/main/java/org/torproject/android/service/vpn/VpnPrefs.java
deleted file mode 100644
index 4945241a..00000000
--- a/orbotOld/src/main/java/org/torproject/android/service/vpn/VpnPrefs.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.torproject.android.service.vpn;
-
-public interface VpnPrefs {
-
- String PREFS_DNS_PORT = "PREFS_DNS_PORT";
-
- String PREFS_KEY_TORIFIED = "PrefTord";
-}
diff --git a/orbotOld/src/main/java/org/torproject/android/service/vpn/VpnUtils.java b/orbotOld/src/main/java/org/torproject/android/service/vpn/VpnUtils.java
deleted file mode 100644
index 604b1c44..00000000
--- a/orbotOld/src/main/java/org/torproject/android/service/vpn/VpnUtils.java
+++ /dev/null
@@ -1,136 +0,0 @@
-package org.torproject.android.service.vpn;
-
-import android.util.Log;
-
-import org.apache.commons.io.IOUtils;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.List;
-
-import static java.lang.Runtime.getRuntime;
-
-public class VpnUtils {
-
- public static int findProcessId(String command) throws IOException {
-
- String[] cmds = {"ps -ef", "ps -A", "toolbox ps"};
-
- for (int i = 0; i < cmds.length; i++) {
- Process procPs = getRuntime().exec(cmds[i]);
-
- BufferedReader reader = new BufferedReader(new InputStreamReader(procPs.getInputStream()));
-
- String line;
- while ((line = reader.readLine()) != null) {
- if (!line.contains("PID") && line.contains(command)) {
- String[] lineParts = line.split("\\s+");
- try {
- return Integer.parseInt(lineParts[1]); //for most devices it is the second
- } catch (NumberFormatException e) {
- return Integer.parseInt(lineParts[0]); //but for samsungs it is the first
- } finally {
- try {
- procPs.destroy();
- } catch (Exception e) {
- }
- }
- }
- }
- }
-
- return -1;
- }
-
- public static void killProcess(File fileProcBin) throws Exception {
- killProcess(fileProcBin, "-9"); // this is -KILL
- }
-
- public static int killProcess(File fileProcBin, String signal) throws Exception {
-
- int procId = -1;
- int killAttempts = 0;
-
- while ((procId = findProcessId(fileProcBin.getName())) != -1) {
- killAttempts++;
- String pidString = String.valueOf(procId);
- boolean itBeDead = killProcess(pidString, signal);
-
- if (!itBeDead) {
-
- String[] cmds = {"", "busybox ", "toolbox "};
-
- for (int i = 0; i < cmds.length; i++) {
-
- Process proc;
-
- try {
- proc = getRuntime().exec(cmds[i] + "killall " + signal + " " + fileProcBin.getName
- ());
- int exitValue = proc.waitFor();
- if (exitValue == 0)
- break;
-
- } catch (IOException ioe) {
- }
- try {
- proc = getRuntime().exec(cmds[i] + "killall " + signal + " " + fileProcBin.getCanonicalPath());
- int exitValue = proc.waitFor();
- if (exitValue == 0)
- break;
-
- } catch (IOException ioe) {
- }
- }
-
-
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- // ignored
- }
-
- }
-
- if (killAttempts > 4)
- throw new Exception("Cannot kill: " + fileProcBin.getAbsolutePath());
- }
-
- return procId;
- }
-
- public static boolean killProcess(String pidString, String signal) throws Exception {
-
- String[] cmds = {"", "toolbox ", "busybox "};
-
- for (int i = 0; i < cmds.length; i++) {
- try {
- Process proc = getRuntime().exec(cmds[i] + "kill " + signal + " " + pidString);
- int exitVal = proc.waitFor();
- List lineErrors = IOUtils.readLines(proc.getErrorStream());
- List lineInputs = IOUtils.readLines(proc.getInputStream());
-
- if (exitVal != 0) {
- Log.d("Orbot.killProcess", "exit=" + exitVal);
- for (String line : lineErrors)
- Log.d("Orbot.killProcess", line);
-
- for (String line : lineInputs)
- Log.d("Orbot.killProcess", line);
-
- } else {
- //it worked, let's exit
- return true;
- }
-
-
- } catch (IOException ioe) {
- Log.e("Orbot.killprcess", "error killing process: " + pidString, ioe);
- }
- }
-
- return false;
- }
-}
diff --git a/orbotOld/src/main/java/org/torproject/android/service/wrapper/LocaleHelper.java b/orbotOld/src/main/java/org/torproject/android/service/wrapper/LocaleHelper.java
deleted file mode 100644
index 71b08d77..00000000
--- a/orbotOld/src/main/java/org/torproject/android/service/wrapper/LocaleHelper.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package org.torproject.android.service.wrapper;
-
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.content.res.Configuration;
-import android.content.res.Resources;
-import android.os.Build;
-import org.torproject.android.service.util.Prefs;
-
-import java.util.Locale;
-
-/**
- * This class is used to change your application locale and persist this change for the next time
- * that your app is going to be used.
- *
- * You can also change the locale of your application on the fly by using the setLocale method.
- *
- * Created by gunhansancar on 07/10/15.
- * https://gunhansancar.com/change-language-programmatically-in-android/
- */
-public class LocaleHelper {
-
- private static final String SELECTED_LANGUAGE = "Locale.Helper.Selected.Language";
-
- public static Context onAttach(Context context) {
- String lang = getPersistedData(context, Locale.getDefault().getLanguage());
- return setLocale(context, lang);
- }
-
- public static Context onAttach(Context context, String defaultLanguage) {
- String lang = getPersistedData(context, defaultLanguage);
- return setLocale(context, lang);
- }
-
- public static String getLanguage(Context context) {
- return getPersistedData(context, Locale.getDefault().getLanguage());
- }
-
- public static Context setLocale(Context context, String language) {
- persist(context, language);
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
- return updateResources(context, language);
- }
-
- return updateResourcesLegacy(context, language);
- }
-
- private static String getPersistedData(Context context, String defaultLanguage) {
- return Prefs.getDefaultLocale();
- }
-
- private static void persist(Context context, String language) {
- Prefs.setDefaultLocale(language);
- }
-
- @TargetApi(Build.VERSION_CODES.N)
- private static Context updateResources(Context context, String language) {
- Locale locale = new Locale(language);
- Locale.setDefault(locale);
-
- Configuration configuration = context.getResources().getConfiguration();
- configuration.setLocale(locale);
- configuration.setLayoutDirection(locale);
-
- return context.createConfigurationContext(configuration);
- }
-
- @SuppressWarnings("deprecation")
- private static Context updateResourcesLegacy(Context context, String language) {
- Locale locale = new Locale(language);
- Locale.setDefault(locale);
-
- Resources resources = context.getResources();
-
- Configuration configuration = resources.getConfiguration();
- configuration.locale = locale;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
- configuration.setLayoutDirection(locale);
- }
-
- resources.updateConfiguration(configuration, resources.getDisplayMetrics());
-
- return context;
- }
-}
\ No newline at end of file
diff --git a/orbotOld/src/main/java/org/torproject/android/service/wrapper/localHelperMethod.java b/orbotOld/src/main/java/org/torproject/android/service/wrapper/localHelperMethod.java
deleted file mode 100644
index 260e7c0a..00000000
--- a/orbotOld/src/main/java/org/torproject/android/service/wrapper/localHelperMethod.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.torproject.android.service.wrapper;
-
-import java.time.LocalDateTime;
-import java.util.Calendar;
-
-public class localHelperMethod
-{
- /*Helper Methods General*/
- public static String getCurrentTime(){
- Calendar now = Calendar.getInstance();
- int year = now.get(Calendar.YEAR);
- int month = now.get(Calendar.MONTH) + 1; // Note: zero based!
- int day = now.get(Calendar.DAY_OF_MONTH);
- int hour = now.get(Calendar.HOUR_OF_DAY);
- int minute = now.get(Calendar.MINUTE);
- int second = now.get(Calendar.SECOND);
- int millis = now.get(Calendar.MILLISECOND);
-
- System.out.printf("%d-%02d-%02d %02d:%02d:%02d.%03d", year, month, day, hour, minute, second, millis);
- return month + "/" + year + " | " + hour + ":" + minute + ":" + second;
- }
-}
diff --git a/orbotOld/src/main/java/org/torproject/android/service/wrapper/logRowModel.java b/orbotOld/src/main/java/org/torproject/android/service/wrapper/logRowModel.java
deleted file mode 100644
index cc72670b..00000000
--- a/orbotOld/src/main/java/org/torproject/android/service/wrapper/logRowModel.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.torproject.android.service.wrapper;
-
-public class logRowModel {
- /*Private Variables*/
-
- private String mLog;
- private String mDate;
-
- /*Initializations*/
-
- public logRowModel(String pLog, String pDate) {
- this.mLog = pLog;
- this.mDate = pDate;
- }
-
- /*Variable Setters*/
-
- public void setLog(String pLog){
- this.mLog = pLog;
- }
- public void setDate(String pDate) {
- mDate = pDate;
- }
-
- /*Variable Getters*/
-
- public String getLog() {
- return mLog;
- }
- public String getDate() {
- return mDate;
- }
-}
diff --git a/orbotOld/src/main/java/org/torproject/android/service/wrapper/orbotLocalConstants.java b/orbotOld/src/main/java/org/torproject/android/service/wrapper/orbotLocalConstants.java
deleted file mode 100644
index 7673076d..00000000
--- a/orbotOld/src/main/java/org/torproject/android/service/wrapper/orbotLocalConstants.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.torproject.android.service.wrapper;
-
-import android.content.Context;
-import android.content.Intent;
-
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-
-public class orbotLocalConstants
-{
- public static ArrayList mTorLogsHistory = new ArrayList<>();
- public static String mTorLogsStatus = "Loading...";
- public static boolean mIsTorInitialized = false;
- public static String mCurrentStatus = "";
- public static int mNotificationStatus = 0;
- public static WeakReference mHomeContext;
- public static Intent mHomeIntent = null;
- public static String mBridges = "";
- public static boolean mIsManualBridge = false;
- public static boolean mNetworkState = true;
-}
diff --git a/orbotOld/src/main/jni/Android.mk b/orbotOld/src/main/jni/Android.mk
deleted file mode 100644
index 10accb58..00000000
--- a/orbotOld/src/main/jni/Android.mk
+++ /dev/null
@@ -1,146 +0,0 @@
-# Copyright (C) 2009 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-#
-LOCAL_PATH := $(call my-dir)
-ROOT_PATH := $(LOCAL_PATH)
-EXTERN_PATH := $(LOCAL_PATH)/../../../../external
-
-########################################################
-## pdnsd library
-########################################################
-
-include $(CLEAR_VARS)
-
-PDNSD_SOURCES := $(wildcard $(LOCAL_PATH)/pdnsd/src/*.c)
-
-LOCAL_MODULE := pdnsd
-LOCAL_SRC_FILES := $(PDNSD_SOURCES:$(LOCAL_PATH)/%=%)
-LOCAL_CFLAGS := -Wall -O2 -I$(LOCAL_PATH)/pdnsd -DHAVE_STPCPY
-
-
-include $(BUILD_EXECUTABLE)
-
-########################################################
-## libancillary
-########################################################
-
-include $(CLEAR_VARS)
-
-ANCILLARY_SOURCE := fd_recv.c fd_send.c
-
-LOCAL_MODULE := libancillary
-LOCAL_CFLAGS := -O2 -I$(LOCAL_PATH)/libancillary
-
-LOCAL_SRC_FILES := $(addprefix libancillary/, $(ANCILLARY_SOURCE))
-
-include $(BUILD_STATIC_LIBRARY)
-
-
-########################################################
-## tun2socks
-########################################################
-
-include $(CLEAR_VARS)
-
-LOCAL_CFLAGS := -std=gnu99
-LOCAL_CFLAGS += -DBADVPN_THREADWORK_USE_PTHREAD -DBADVPN_LINUX -DBADVPN_BREACTOR_BADVPN -D_GNU_SOURCE
-LOCAL_CFLAGS += -DBADVPN_USE_SELFPIPE -DBADVPN_USE_EPOLL
-LOCAL_CFLAGS += -DBADVPN_LITTLE_ENDIAN -DBADVPN_THREAD_SAFE
-LOCAL_CFLAGS += -DNDEBUG -DANDROID
-LOCAL_CFLAGS += -DTUN2SOCKS_JNI
-LOCAL_CFLAGS += -DPSIPHON
-
-LOCAL_STATIC_LIBRARIES := libancillary
-
-LOCAL_C_INCLUDES:= \
- $(LOCAL_PATH)/libancillary \
- $(EXTERN_PATH)/badvpn/ \
- $(EXTERN_PATH)/badvpn/lwip/src/include/ipv4 \
- $(EXTERN_PATH)/badvpn/lwip/src/include/ipv6 \
- $(EXTERN_PATH)/badvpn/lwip/src/include \
- $(EXTERN_PATH)/badvpn/lwip/custom \
-
-TUN2SOCKS_SOURCES := \
- base/BLog_syslog.c \
- system/BReactor_badvpn.c \
- system/BSignal.c \
- system/BConnection_unix.c \
- system/BTime.c \
- system/BUnixSignal.c \
- system/BNetwork.c \
- flow/StreamRecvInterface.c \
- flow/PacketRecvInterface.c \
- flow/PacketPassInterface.c \
- flow/StreamPassInterface.c \
- flow/SinglePacketBuffer.c \
- flow/BufferWriter.c \
- flow/PacketBuffer.c \
- flow/PacketStreamSender.c \
- flow/PacketPassConnector.c \
- flow/PacketProtoFlow.c \
- flow/PacketPassFairQueue.c \
- flow/PacketProtoEncoder.c \
- flow/PacketProtoDecoder.c \
- socksclient/BSocksClient.c \
- tuntap/BTap.c \
- lwip/src/core/timers.c \
- lwip/src/core/udp.c \
- lwip/src/core/memp.c \
- lwip/src/core/init.c \
- lwip/src/core/pbuf.c \
- lwip/src/core/tcp.c \
- lwip/src/core/tcp_out.c \
- lwip/src/core/netif.c \
- lwip/src/core/def.c \
- lwip/src/core/mem.c \
- lwip/src/core/tcp_in.c \
- lwip/src/core/stats.c \
- lwip/src/core/inet_chksum.c \
- lwip/src/core/ipv4/icmp.c \
- lwip/src/core/ipv4/igmp.c \
- lwip/src/core/ipv4/ip4_addr.c \
- lwip/src/core/ipv4/ip_frag.c \
- lwip/src/core/ipv4/ip4.c \
- lwip/src/core/ipv4/autoip.c \
- lwip/src/core/ipv6/ethip6.c \
- lwip/src/core/ipv6/inet6.c \
- lwip/src/core/ipv6/ip6_addr.c \
- lwip/src/core/ipv6/mld6.c \
- lwip/src/core/ipv6/dhcp6.c \
- lwip/src/core/ipv6/icmp6.c \
- lwip/src/core/ipv6/ip6.c \
- lwip/src/core/ipv6/ip6_frag.c \
- lwip/src/core/ipv6/nd6.c \
- lwip/custom/sys.c \
- tun2socks/tun2socks.c \
- base/DebugObject.c \
- base/BLog.c \
- base/BPending.c \
- system/BDatagram_unix.c \
- flowextra/PacketPassInactivityMonitor.c \
- tun2socks/SocksUdpGwClient.c \
- udpgw_client/UdpGwClient.c
-
-LOCAL_MODULE := tun2socks
-
-LOCAL_LDLIBS := -ldl -llog
-
-LOCAL_SRC_FILES := $(addprefix ../../../../external/badvpn/, $(TUN2SOCKS_SOURCES))
-
-##include $(BUILD_EXECUTABLE)
-include $(BUILD_SHARED_LIBRARY)
-
-# Import cpufeatures
-$(call import-module,android/cpufeatures)
diff --git a/orbotOld/src/main/jni/Application.mk b/orbotOld/src/main/jni/Application.mk
deleted file mode 100644
index 334c62fe..00000000
--- a/orbotOld/src/main/jni/Application.mk
+++ /dev/null
@@ -1,3 +0,0 @@
-APP_ABI := armeabi-v7a x86 arm64-v8a x86_64
-APP_PLATFORM := android-16
-APP_STL := c++_static
diff --git a/orbotOld/src/main/jni/libancillary/API b/orbotOld/src/main/jni/libancillary/API
deleted file mode 100644
index b558995a..00000000
--- a/orbotOld/src/main/jni/libancillary/API
+++ /dev/null
@@ -1,139 +0,0 @@
- This library provide an easy interface to the black magic that can be done
- on Unix domain sockets, like passing file descriptors from one process to
- another.
-
- Programs that uses this library should include the ancillary.h header file.
- Nothing else is required.
-
- All functions of this library require the following header:
-
- #include
-
- At this time, the only ancillary data defined by the Single Unix
- Specification (v3) is file descriptors.
-
-Passing file descriptors
-
- int ancil_send_fd(socket, file_descriptor)
- int socket: the Unix socket
- int file_descriptor: the file descriptor
- Return value: 0 for success, -1 for failure.
-
- Sends one file descriptor on a socket.
- In case of failure, errno is set; the possible values are the ones of the
- sendmsg(2) system call.
-
-
- int ancil_recv_fd(socket, file_descriptor)
- int socket: the Unix socket
- int *file_descriptor: pointer to the returned file descriptor
- Return value: 0 for success, -1 for failure
-
- Receives one file descriptor from a socket.
- In case of success, the file descriptor is stored in the integer pointed
- to by file_descriptor.
- In case of failure, errno is set; the possible values are the ones of the
- recvmsg(2) system call.
- The behavior is undefined if the recv_fd does not match a send_fd* on the
- other side.
-
-
- int ancil_send_fds(socket, file_descriptors, num_file_descriptors)
- int socket: the Unix socket
- const int *file_descriptors: array of file descriptors
- unsigned num_file_descriptors: number of file descriptors
- Return value: 0 for success, -1 for failure
-
- Sends several file descriptors on a socket.
- In case of failure, errno is set; the possible values are the ones of the
- sendmsg(2) system call.
- The maximum number of file descriptors that can be sent using this
- function is ANCIL_MAX_N_FDS; the behavior is undefined in case of
- overflow, probably a stack corruption.
-
-
- int ancil_recv_fds(socket, file_descriptors, num_file_descriptors)
- int socket: the Unix socket
- int *file_descriptors: return array of file descriptors
- unsigned num_file_descriptors: number of file descriptors
- Return value: number of received fd for success, -1 for failure
-
- Receives several file descriptors from a socket, no more than
- num_file_descriptors.
- In case of success, the received file descriptors are stored in the array
- pointed to by file_descriptors.
- In case of failure, errno is set; the possible values are the ones of the
- recvmsg(2) system call.
- The maximum number of file descriptors that can be received using this
- function is ANCIL_MAX_N_FDS; the behavior is undefined in case of
- overflow, probably a stack corruption.
- The behavior is undefined if the recv_fds does not match a send_fd* on
- the other side, or if the number of received file descriptors is more than
- num_file_descriptors.
-
-
- int ancil_send_fds_with_buffer(socket, fds, num, buffer)
- int socket: the Unix socket
- const int *fds: array of file descriptors
- unsigned num: number of file descriptors
- void *buffer: buffer to hold the system data structures
- Return value: 0 for success, -1 for failure
-
- Sends several file descriptors on a socket.
- In case of failure, errno is set; the possible values are the ones of the
- sendmsg(2) system call.
- The buffer argument must point to a memory area large enough to hold the
- system data structures, see ANCIL_FD_BUFFER.
-
-
- int ancil_send_fds_with_buffer(socket, fds, num, buffer)
- int socket: the Unix socket
- int *fds: return array of file descriptors
- unsigned num: number of file descriptors
- void *buffer: buffer to hold the system data structures
- Return value: number of received fd for success, -1 for failure
-
- Receives several file descriptors from a socket, no more than
- num_file_descriptors.
- In case of success, the received file descriptors are stored in the array
- pointed to by file_descriptors.
- In case of failure, errno is set; the possible values are the ones of the
- recvmsg(2) system call.
- The behavior is undefined if the recv_fds does not match a send_fd* on
- the other side, or if the number of received file descriptors is more than
- num_file_descriptors.
- The buffer argument must point to a memory area large enough to hold the
- system data structures, see ANCIL_FD_BUFFER.
-
-
- ANCIL_MAX_N_FDS
-
- Maximum number of file descriptors that can be sent with the sent_fds and
- recv_fds functions. If you have to send more at once, use the
- *_with_buffer versions. The value is enough to send "quite a few" file
- descriptors.
-
-
- ANCIL_FD_BUFFER(n)
- int n: number of file descriptors
-
- Expands to a structure data type large enough to hold the system data
- structures for n file descriptors. So the address of a variable declared
- of type ANCIL_FD_BUFFER(n) is suitable as the buffer argument for
- *_with_buffer on n file descriptors.
- To use this macro, you need and . Bevare: with
- Solaris, the _XPG4_2 macro must be defined before sys/socket is included.
-
-
-Tuning the compilation
-
- This library is designed to be included in projects, not installed in
- /usr/lib. If your project does not use some of the functions, the
- TUNE_OPTS variable in the Makefile allows not to build them. It is a list
- of proprocessor options:
-
- -DNDEBUG: turn assertions off (see assert(3))
- -DSPARE_SEND_FDS: do not build ancil_send_fds
- -DSPARE_SEND_FD: do not build ancil_send_fd
- -DSPARE_RECV_FDS: do not build ancil_recv_fds
- -DSPARE_RECV_FD: do not build ancil_recv_fd
diff --git a/orbotOld/src/main/jni/libancillary/COPYING b/orbotOld/src/main/jni/libancillary/COPYING
deleted file mode 100644
index 5bcd9c2b..00000000
--- a/orbotOld/src/main/jni/libancillary/COPYING
+++ /dev/null
@@ -1,21 +0,0 @@
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/orbotOld/src/main/jni/libancillary/Makefile b/orbotOld/src/main/jni/libancillary/Makefile
deleted file mode 100644
index 3d32533f..00000000
--- a/orbotOld/src/main/jni/libancillary/Makefile
+++ /dev/null
@@ -1,73 +0,0 @@
-###########################################################################
-# libancillary - black magic on Unix domain sockets
-# (C) Nicolas George
-# Makefile - guess what
-###########################################################################
-
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-#
-# 1. Redistributions of source code must retain the above copyright notice,
-# this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# 3. The name of the author may not be used to endorse or promote products
-# derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
-# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-CC=gcc
-CFLAGS=-Wall -g -O2
-LDFLAGS=
-LIBS=
-AR=ar
-RANLIB=ranlib
-RM=rm
-CP=cp
-MKDIR=mkdir
-TAR=tar
-GZIP=gzip -9
-
-NAME=libancillary
-DISTRIBUTION=API COPYING Makefile ancillary.h fd_send.c fd_recv.c test.c
-VERSION=0.9.1
-
-OBJECTS=fd_send.o fd_recv.o
-
-TUNE_OPTS=-DNDEBUG
-#TUNE_OPTS=-DNDEBUG \
- -DSPARE_SEND_FDS -DSPARE_SEND_FD -DSPARE_RECV_FDS -DSPARE_RECV_FD
-
-.c.o:
- $(CC) -c $(CFLAGS) $(TUNE_OPTS) $<
-
-all: libancillary.a
-
-libancillary.a: $(OBJECTS)
- $(AR) cr $@ $(OBJECTS)
- $(RANLIB) $@
-
-fd_send.o: ancillary.h
-fd_recv.o: ancillary.h
-
-test: test.c libancillary.a
- $(CC) -o $@ $(CFLAGS) $(LDFLAGS) -L. test.c -lancillary $(LIBS)
-
-clean:
- -$(RM) -f *.o *.a test
-
-dist:
- $(MKDIR) $(NAME)-$(VERSION)
- $(CP) $(DISTRIBUTION) $(NAME)-$(VERSION)
- $(TAR) -cf - $(NAME)-$(VERSION) | $(GZIP) > $(NAME)-$(VERSION).tar.gz
- $(RM) -rf $(NAME)-$(VERSION)
diff --git a/orbotOld/src/main/jni/libancillary/ancillary.h b/orbotOld/src/main/jni/libancillary/ancillary.h
deleted file mode 100644
index 636d8677..00000000
--- a/orbotOld/src/main/jni/libancillary/ancillary.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/***************************************************************************
- * libancillary - black magic on Unix domain sockets
- * (C) Nicolas George
- * ancillary.c - public header
- ***************************************************************************/
-
-/*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ANCILLARY_H__
-#define ANCILLARY_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/***************************************************************************
- * Start of the readable part.
- ***************************************************************************/
-
-#define ANCIL_MAX_N_FDS 960
-/*
- * Maximum number of fds that can be sent or received using the "esay"
- * functions; this is so that all can fit in one page.
- */
-
-extern int
-ancil_send_fds_with_buffer(int, const int *, unsigned, void *);
-/*
- * ancil_send_fds_with_buffer(sock, n_fds, fds, buffer)
- *
- * Sends the file descriptors in the array pointed by fds, of length n_fds
- * on the socket sock.
- * buffer is a writeable memory area large enough to hold the required data
- * structures.
- * Returns: -1 and errno in case of error, 0 in case of success.
- */
-
-extern int
-ancil_recv_fds_with_buffer(int, int *, unsigned, void *);
-/*
- * ancil_recv_fds_with_buffer(sock, n_fds, fds, buffer)
- *
- * Receives *n_fds file descriptors into the array pointed by fds
- * from the socket sock.
- * buffer is a writeable memory area large enough to hold the required data
- * structures.
- * Returns: -1 and errno in case of error, the actual number of received fd
- * in case of success
- */
-
-#define ANCIL_FD_BUFFER(n) \
- struct { \
- struct cmsghdr h; \
- int fd[n]; \
- }
-/* ANCIL_FD_BUFFER(n)
- *
- * A structure type suitable to be used as buffer for n file descriptors.
- * Requires .
- * Example:
- * ANCIL_FD_BUFFER(42) buffer;
- * ancil_recv_fds_with_buffer(sock, 42, my_fds, &buffer);
- */
-
-extern int
-ancil_send_fds(int, const int *, unsigned);
-/*
- * ancil_send_fds(sock, n_fds, fds)
- *
- * Sends the file descriptors in the array pointed by fds, of length n_fds
- * on the socket sock.
- * n_fds must not be greater than ANCIL_MAX_N_FDS.
- * Returns: -1 and errno in case of error, 0 in case of success.
- */
-
-extern int
-ancil_recv_fds(int, int *, unsigned);
-/*
- * ancil_recv_fds(sock, n_fds, fds)
- *
- * Receives *n_fds file descriptors into the array pointed by fds
- * from the socket sock.
- * *n_fds must not be greater than ANCIL_MAX_N_FDS.
- * Returns: -1 and errno in case of error, the actual number of received fd
- * in case of success.
- */
-
-
-extern int
-ancil_send_fd(int, int);
-/* ancil_recv_fd(sock, fd);
- *
- * Sends the file descriptor fd on the socket sock.
- * Returns : -1 and errno in case of error, 0 in case of success.
- */
-
-extern int
-ancil_recv_fd(int, int *);
-/* ancil_send_fd(sock, &fd);
- *
- * Receives the file descriptor fd from the socket sock.
- * Returns : -1 and errno in case of error, 0 in case of success.
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ANCILLARY_H__ */
diff --git a/orbotOld/src/main/jni/libancillary/fd_recv.c b/orbotOld/src/main/jni/libancillary/fd_recv.c
deleted file mode 100644
index 46c2e694..00000000
--- a/orbotOld/src/main/jni/libancillary/fd_recv.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/***************************************************************************
- * libancillary - black magic on Unix domain sockets
- * (C) Nicolas George
- * fd_send.c - receiving file descriptors
- ***************************************************************************/
-
-/*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _XPG4_2 /* Solaris sucks */
-# define _XPG4_2
-#endif
-
-#include
-#include
-#include
-#include
-#include
-#if defined(__FreeBSD__)
-# include /* FreeBSD sucks */
-#endif
-
-#include "ancillary.h"
-
-int
-ancil_recv_fds_with_buffer(int sock, int *fds, unsigned n_fds, void *buffer)
-{
- struct msghdr msghdr;
- char nothing;
- struct iovec nothing_ptr;
- struct cmsghdr *cmsg;
- int i;
-
- nothing_ptr.iov_base = ¬hing;
- nothing_ptr.iov_len = 1;
- msghdr.msg_name = NULL;
- msghdr.msg_namelen = 0;
- msghdr.msg_iov = ¬hing_ptr;
- msghdr.msg_iovlen = 1;
- msghdr.msg_flags = 0;
- msghdr.msg_control = buffer;
- msghdr.msg_controllen = sizeof(struct cmsghdr) + sizeof(int) * n_fds;
- cmsg = CMSG_FIRSTHDR(&msghdr);
- cmsg->cmsg_len = msghdr.msg_controllen;
- cmsg->cmsg_level = SOL_SOCKET;
- cmsg->cmsg_type = SCM_RIGHTS;
- for(i = 0; i < n_fds; i++)
- ((int *)CMSG_DATA(cmsg))[i] = -1;
-
- if(recvmsg(sock, &msghdr, 0) < 0)
- return(-1);
- for(i = 0; i < n_fds; i++)
- fds[i] = ((int *)CMSG_DATA(cmsg))[i];
- n_fds = (msghdr.msg_controllen - sizeof(struct cmsghdr)) / sizeof(int);
- return(n_fds);
-}
-
-#ifndef SPARE_RECV_FDS
-int
-ancil_recv_fds(int sock, int *fd, unsigned n_fds)
-{
- ANCIL_FD_BUFFER(ANCIL_MAX_N_FDS) buffer;
-
- assert(n_fds <= ANCIL_MAX_N_FDS);
- return(ancil_recv_fds_with_buffer(sock, fd, n_fds, &buffer));
-}
-#endif /* SPARE_RECV_FDS */
-
-#ifndef SPARE_RECV_FD
-int
-ancil_recv_fd(int sock, int *fd)
-{
- ANCIL_FD_BUFFER(1) buffer;
-
- return(ancil_recv_fds_with_buffer(sock, fd, 1, &buffer) == 1 ? 0 : -1);
-}
-#endif /* SPARE_RECV_FD */
diff --git a/orbotOld/src/main/jni/libancillary/fd_send.c b/orbotOld/src/main/jni/libancillary/fd_send.c
deleted file mode 100644
index 01de87fd..00000000
--- a/orbotOld/src/main/jni/libancillary/fd_send.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/***************************************************************************
- * libancillary - black magic on Unix domain sockets
- * (C) Nicolas George
- * fd_send.c - sending file descriptors
- ***************************************************************************/
-
-/*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _XPG4_2 /* Solaris sucks */
-# define _XPG4_2
-#endif
-
-#include
-#include
-#include
-#include
-#include
-#if defined(__FreeBSD__)
-# include /* FreeBSD sucks */
-#endif
-
-#include "ancillary.h"
-
-int
-ancil_send_fds_with_buffer(int sock, const int *fds, unsigned n_fds, void *buffer)
-{
- struct msghdr msghdr;
- char nothing = '!';
- struct iovec nothing_ptr;
- struct cmsghdr *cmsg;
- int i;
-
- nothing_ptr.iov_base = ¬hing;
- nothing_ptr.iov_len = 1;
- msghdr.msg_name = NULL;
- msghdr.msg_namelen = 0;
- msghdr.msg_iov = ¬hing_ptr;
- msghdr.msg_iovlen = 1;
- msghdr.msg_flags = 0;
- msghdr.msg_control = buffer;
- msghdr.msg_controllen = sizeof(struct cmsghdr) + sizeof(int) * n_fds;
- cmsg = CMSG_FIRSTHDR(&msghdr);
- cmsg->cmsg_len = msghdr.msg_controllen;
- cmsg->cmsg_level = SOL_SOCKET;
- cmsg->cmsg_type = SCM_RIGHTS;
- for(i = 0; i < n_fds; i++)
- ((int *)CMSG_DATA(cmsg))[i] = fds[i];
- return(sendmsg(sock, &msghdr, 0) >= 0 ? 0 : -1);
-}
-
-#ifndef SPARE_SEND_FDS
-int
-ancil_send_fds(int sock, const int *fds, unsigned n_fds)
-{
- ANCIL_FD_BUFFER(ANCIL_MAX_N_FDS) buffer;
-
- assert(n_fds <= ANCIL_MAX_N_FDS);
- return(ancil_send_fds_with_buffer(sock, fds, n_fds, &buffer));
-}
-#endif /* SPARE_SEND_FDS */
-
-#ifndef SPARE_SEND_FD
-int
-ancil_send_fd(int sock, int fd)
-{
- ANCIL_FD_BUFFER(1) buffer;
-
- return(ancil_send_fds_with_buffer(sock, &fd, 1, &buffer));
-}
-#endif /* SPARE_SEND_FD */
diff --git a/orbotOld/src/main/jni/libancillary/test.c b/orbotOld/src/main/jni/libancillary/test.c
deleted file mode 100644
index d3c1fdac..00000000
--- a/orbotOld/src/main/jni/libancillary/test.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/***************************************************************************
- * libancillary - black magic on Unix domain sockets
- * (C) Nicolas George
- * test.c - testing and example program
- ***************************************************************************/
-
-/*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include "ancillary.h"
-
-void child_process(int sock)
-{
- int fd;
- int fds[3], nfds;
- char b[] = "This is on the received fd!\n";
-
- if(ancil_recv_fd(sock, &fd)) {
- perror("ancil_recv_fd");
- exit(1);
- } else {
- printf("Received fd: %d\n", fd);
- }
- write(fd, b, sizeof(b));
- close(fd);
- sleep(2);
-
- nfds = ancil_recv_fds(sock, fds, 3);
- if(nfds < 0) {
- perror("ancil_recv_fds");
- exit(1);
- } else {
- printf("Received %d/3 fds : %d %d %d.\n", nfds,
- fds[0], fds[1], fds[2]);
- }
-}
-
-void parent_process(int sock)
-{
- int fds[2] = { 1, 2 };
-
- if(ancil_send_fd(sock, 1)) {
- perror("ancil_send_fd");
- exit(1);
- } else {
- printf("Sent fd.\n");
- }
- sleep(1);
-
- if(ancil_send_fds(sock, fds, 2)) {
- perror("ancil_send_fds");
- exit(1);
- } else {
- printf("Sent two fds.\n");
- }
-}
-
-int main(void)
-{
- int sock[2];
-
- if(socketpair(PF_UNIX, SOCK_STREAM, 0, sock)) {
- perror("socketpair");
- exit(1);
- } else {
- printf("Established socket pair: (%d, %d)\n", sock[0], sock[1]);
- }
-
- switch(fork()) {
- case 0:
- close(sock[0]);
- child_process(sock[1]);
- break;
- case -1:
- perror("fork");
- exit(1);
- default:
- close(sock[1]);
- parent_process(sock[0]);
- wait(NULL);
- break;
- }
- return(0);
-}
diff --git a/orbotOld/src/main/jni/pdnsd/AUTHORS b/orbotOld/src/main/jni/pdnsd/AUTHORS
deleted file mode 100644
index fa0454e4..00000000
--- a/orbotOld/src/main/jni/pdnsd/AUTHORS
+++ /dev/null
@@ -1,58 +0,0 @@
-Most of pdnsd was written by Thomas Moestl (tmoestl@gmx.net).
-In the "par" versions large parts of the code have been revised
-and several features have been added by Paul Rombouts.
-
-Small parts of this program are based on code that was taken from nmap (IP
-checksumming), the isdn4k-utils (ippp interface uptest), glibc 2.1.2 (some
-definitions for kernel 2.2.x missing in 2.0 glibcs) and FreeBSD
-(SIZEOF_ADDR_IFREQ in netdev.c).
-nmap was written by Fyodor. The insd4k-utils were written by Fritz Elfert and
-others. The GNU C library (glibc) is copyright by the Free Software
-Foundation.
-
-The following people have contributed code:
-Andrew M. Bishop contributed support for server labels
-Carsten Block contributed 'configure'-able rc scripts
-Stephan Boettcher contributed the SCHEME= option.
-P.J. Bostley contributed patches to get pdnsd working on
- alpha
-Frank Elsner contributed rc script fixes
-Christian Engstler contributed patches for SuSE compatability
-Bjoern Fischer contributed code to make pdnsd leave the case of names
- in the cache unchanged
-Torben Janssen contributed RedHat rc scripts
-Olaf Kirch contributed a security fix for the run_as()
- function
-Bernd Leibing contributed fixes to the spec file.
-Sourav K. Mandal contributed the autoconf/automake code, gdbm
- caching facility and many suggestions
-Markus Mohr contributed Debian rc scripts
-Alexandre Nunes contributed autoconf fixes
-Wolfgang Ocker contributed the server_ip option
-Soenke J. Peters contributed patches and suggestions for RedHat
- compatability
-Roman Shterenzon contributed many helpful hints and patches for
- FreeBSD compatability.
-Andreas Steinmetz contributed the code for the query_port_start and
- query_port_end options (which I changed slightly,
- so blame any breakage on me ;)
-Marko Stolle contributed the contrib/pdnsd_update.pl script that
- makes pdnsd usable in a DHCP setup.
-Lyonel Vincent extended the serve_aliases option to support an
- arbitrary number of aliases
-Paul Wagland contributed a patches for bind9-compatability
- and for some memory leaks on error paths.
-Sverker Wiberg contributed IPv6 build fixes
-Michael Wiedmann contributed the pdnsd-ctl.8 man page.
-Ron Yorston contributed the dev-uptest for Linux ppp dial-
- on-demand devices
-Nikita V. Youshchenko contributed extensions to the "if" uptest
-Mahesh T. Pai contributed the pdnsd.8 man page.
-Nikola Kotur contributed the Slackware start-up script.
-Kiyo Kelvin Lee contributed a patch for Cygwin support.
-Rodney Brown contributed a patch for Darwin (Apple Mac OS X) support.
-Jan-Marek Glogowski contributed a patch implementing the "use_nss" option.
-
-Please look into the THANKS file for people who helped me in various ways on
-this project.
-If this list is incomplete, pease drop me a mail!
diff --git a/orbotOld/src/main/jni/pdnsd/COPYING b/orbotOld/src/main/jni/pdnsd/COPYING
deleted file mode 100644
index 94a9ed02..00000000
--- a/orbotOld/src/main/jni/pdnsd/COPYING
+++ /dev/null
@@ -1,674 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-
- Copyright (C)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- Copyright (C)
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
- .
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-.
diff --git a/orbotOld/src/main/jni/pdnsd/COPYING.BSD b/orbotOld/src/main/jni/pdnsd/COPYING.BSD
deleted file mode 100644
index 99fe14ae..00000000
--- a/orbotOld/src/main/jni/pdnsd/COPYING.BSD
+++ /dev/null
@@ -1,26 +0,0 @@
-A small part of the pdnsd source is licensed under the following BSD-style
-license:
-
-Copyright (C) 2001 Thomas Moestl
-
-This file is part of the pdnsd package.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
-USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/orbotOld/src/main/jni/pdnsd/ChangeLog b/orbotOld/src/main/jni/pdnsd/ChangeLog
deleted file mode 100644
index fe774653..00000000
--- a/orbotOld/src/main/jni/pdnsd/ChangeLog
+++ /dev/null
@@ -1,3304 +0,0 @@
-2012-04-23 Paul A. Rombouts
-
- * src/dns_query.c
- Refine the return values of p_dns_cached_resolve(), p_dns_resolve() and
- p_recursive_query() so that they distinguish between answers found in
- the cache and replies obtained by querying other servers.
- This, among other things, can be used to prevent data that was recently
- obtained from the cache needlessly being added back to the cache.
-
-2012-04-22 Paul A. Rombouts
-
- * configure.in
- On the Linux platform, check if we can compile and link with the
- -pthread flag instead of linking with -lpthread.
-
-2012-04-21 Paul A. Rombouts
-
- * src/dns_query.c
- When following the delegation chain trying to get an authoritative
- answer, pdnsd would answer with SERVFAIL if it failed to get a reply
- from the last server in the chain. Instead pdnsd will now use the last
- reply in the chain with RCode=0 that raised the AA or RA flag, if there
- is one.
-
-2012-04-19 Paul A. Rombouts
-
- * src/cache.c
- In report_cache_stat(), make copies of volatile data to get a
- consistent data set before making calculations with cache size and
- entry numbers.
-
-2012-04-16 Paul A. Rombouts
-
- * src/netdev.c
- If we can't open /proc/net/if_inet6 in is_local_addr() log a warning
- message.
-
-2012-04-15 Paul A. Rombouts
-
- * src/dns_query.c
- The code checking for duplicate IP addresses obtained from NS records
- in auth_ok() has been slightly optimized.
-
-2012-04-12 Paul A. Rombouts
-
- * src/dns_query.c
- When resolving nameservers obtained from NS records, allow pdnsd to use
- more than one IP address per nameserver.
- In rare cases, using just one IP address for each nameserver will cause
- unnecessary resolve failures if the address chosen for each nameserver
- happens to be unreachable while the other addresses would lead to
- successful resolution, as demonstrated by Yuri Vorobyev.
-
-2012-03-16 Paul A. Rombouts
-
- * src/cache.c
- When adding RR records one by one to a cache entry using add_cent_rr(),
- use the smallest ttl value in case of conflicting ttls.
- Code for local/nonlocal conflict resolution has been taken out of
- add_cent_rr_int() and put into add_cent_rr() and cr_check_add()
- which should be slightly more efficient.
-
-2012-03-15 Paul A. Rombouts
-
- * src/dns_query.c
- Enforcing strict RFC 2181 compliance by rejecting all the answers
- with inconsistent ttl timestamps can cause undesirable resolve failures.
- I have tried to implement a more compromising solution, whereby
- inconsistent answers that should be normally rejected are still never
- cached, but are nevertheless used as intermediary or temporary results
- if all else fails.
-
-2012-03-13 Paul A. Rombouts
-
- * src/dns_query.c
- Fixed a typo in rr_to_cache() that caused pdnsd to fail to compile when
- configured with the --enable-strict-rfc2181 option.
- Thanks to Gonzalo L. R. for reporting this problem.
- Also changed the return value of rr_to_cache() from a simple boolean to
- an RC code in order to properly distinguish between memory allocation
- errors and time-stamp inconsistencies.
-
-2012-02-21 Paul A. Rombouts
-
- * src/dns_query.c
- If we have used EDNS in a query and the remote server answered
- with rcode "format error", try again with the OPT pseudo-record
- removed from the additional section of the query.
-
- Also fixed a bug in p_exec_query() that caused pdnsd to behave
- as if every reply with a non-empty additional section contained
- an OPT record.
-
-2012-02-15 Paul A. Rombouts
-
- * src/dns_answer.c,src/helpers.c,src/helpers.h,src/icmp.c,
- src/ipvers.h,src/main.c,src/netdev.c
- Introduced a new macro SEL_IPVER() to reduce some of the clutter in the
- code caused by having to support both IPv4 and IPv6.
-
-2012-01-31 Paul A. Rombouts
-
- * configure.in
- Add AM_PROG_CC_C_O line to configure.in to prevent automake warning.
-
-2012-01-29 Paul A. Rombouts
-
- * src/cache.c
- In report_cache_stat(), add the average number of bytes used per cache
- entry when reporting the cache status, as suggested by M. Galabant.
-
-2012-01-28 Paul A. Rombouts
-
- * src/dns_answer.c,src/dns_query.c
- Cleaned up the code a bit to avoid warning messages when
- compiling with '-Wall -Winline' flags.
-
-2012-01-18 Paul A. Rombouts
-
- * src/conff.c
- Set the default of the edns_query option to false.
-
-2011-07-31 Paul Rombouts
-
- * src/cache.c
- Use a slightly more sophisticated merge-sort algorithm in sort_rrl().
-
-2011-05-09 Paul Rombouts
-
- * src/dns_answer.c
- In compose_answer(), also add an OPT pseudo-RR to the additional section
- of a NXDOMAIN reply when appropriate.
-
-2011-05-08 Paul Rombouts
-
- * src/cache.c,src/cache.h,src/dns_query.c,src/status.c
- Make the dns_cent_t struct more compact by putting the fields that are
- only used for either non-existent or existent domains, but not both,
- into a union so that these fields can share memory.
- When saving the cache to file, only write the TTL and time-stamp for
- a whole domain when it is negatively cached.
-
-2011-05-06 Paul Rombouts
-
- * src/cache.c,src/cache.h,src/dns_query.c
- At the request of Andrei Caraman, the TTL of a negatively cached domain
- is now adjusted in accordance with the min_ttl and max_ttl options, just
- as it is done for (negatively) cached records.
- Additional change to the TTL policy is that for negative records (and
- negative domains) the neg_ttl setting overrides min_ttl if
- neg_ttl < min_ttl.
-
-2011-04-26 Paul Rombouts
-
- * src/conf-parser.c
- Fixed memory leak that can occur when the configuration file is reloaded
- and an error is encountered while parsing the definition of a TXT
- record.
-
-2011-03-21 Paul Rombouts
-
- * src/make_rr_types_h.pl,src/cache.h,src/cache.c,src/dns_answer.c
- Introduced arrays rrmuiterlist and rrcachiterlist to make iterating
- over all possible RR types in a cache entry in strict ascending order
- a little more efficient.
-
-2011-03-09 Paul Rombouts
-
- * src/dns_query.c,src/conf-parser.c,src/conf-keywords.h
- Implemented a new config option "outgoing_ip", which
- makes it possible to bind outgoing connections to
- a specific interface.
-
-2011-02-21 Paul Rombouts
-
- * src/netdev.c
- Fixed UDP socket descriptors leak in the implementation of
- is_local_addr() for the FreeBSD platform. Thanks to Ashish Shukla for
- reporting this bug.
-
-2011-02-14 Paul Rombouts
-
- * src/cache.c
- In purge_all_rrsets(), also free the rrext array if it has become empty after
- purging all the RR sets.
-
-2011-02-04 Paul Rombouts
-
- * src/conff.c,src/conff.h,src/conf-parser.c,src/conf-keywords.h,
- src/dns_query.c,src/dns_query.h,src/servers.c
- Changed "edns_query" from a "global" option to a "server"
- configuration option.
-
-2011-02-04 Paul Rombouts
-
- * src/conff.c,src/conff.h,src/dns_query.c,src/dns_query.h,src/servers.c,
- src/conf-parser.c
- The query uptest sometimes fails because some DNS servers are configured
- to ignore empty queries. The new config option "query_test_name" makes
- it possible to query for a specific name instead.
-
-2011-02-01 Paul Rombouts
-
- * src/dns_query.c
- When processing a reply from a remote name server which seems to delegate
- to other name servers, check if the names for which NS records have
- been supplied have locally defined NS records. If so, the local
- records will now override those supplied by the remote server.
-
-2011-01-31 Paul Rombouts
-
- * src/conf-parser.c
- Added support for defining TXT records in the configuration file.
-
-2011-01-30 Paul Rombouts
-
- * src/dns_query.c
- Do not cache additional records from a response that is rejected because
- it contains IP addresses in the reject list, even when the reply
- is processed as a NXDOMAIN reply.
-
-2011-01-25 Paul Rombouts
-
- * src/conf-parser.c
- Modified the function scan_string() to allow back-slashed escape
- sequences in strings.
-
-2011-01-21 Paul Rombouts
-
- * src/dns_answer.c,src/dns_query.c,src/conff.h,src/conff.c,
- src/conf-parser.c
- Added support for EDNS (Extension mechanisms for DNS).
- Currently this is only useful for allowing UDP message sizes
- to be larger than 512 bytes.
-
-2011-01-20 Paul Rombouts
-
- * src/dns_answer.c
- To avoid frequent reallocs when composing a DNS reply message,
- grow the message buffer in multiples of a certain minimum chunk size.
-
-2011-01-19 Paul Rombouts
-
- * src/dns.c,src/dns.h,src/dns_answer.c
- Extended debugging info with DNS-message lengths and flags of incoming
- messages.
-
-2011-01-17 Paul Rombouts
-
- * src/conff.c,src/conff.h,src/conf-parser.c,src/dns_answer.c
- Made "ignore_cd" option obsolete. It is now effectively always on.
-
-2010-12-27 Paul Rombouts
-
- * src/cache.c,src/cache.h,src/dns_answer.c,src/dns_query.c,
- src/make_rr_types.pl,src/rr_types.in,src/rr_types.c
- The array of pointers to rr_set_t structs in the dns_cent_t struct
- contains mostly null pointers in practice, so is somewhat
- inefficient in storage usage. This problem is exacerbated if we add
- support for caching more RR-types. To ameliorate to the problem
- I have decided to split the array in two, with one part fixed in the
- dns_cent_t struct as before, and an extension part that will be
- separately allocated, if necessary. If the extension part is used only
- for very rarely cached types, in most cases the extension array will not
- need to be allocated thus hopefully saving memory overall.
- The lookup tables which are necessary to support the new cache entry
- structure are cumbersome to write by hand, so I have written a perl
- script to do this automatically. As an additional benefit, which RR
- types are cache-able is now configurable for each type separately via
- rr_types.in.
-
-2010-03-14 Paul Rombouts
-
- * src/dns_query.c
- Using randomized source ports for outgoing queries in IPv6 mode failed
- with the warning "Out of ports in the range 1024-65535, dropping query!",
- because the pdnsd tried to bind to the fixed port for incoming queries,
- instead of the dynamically chosen port. This is a very old bug, but it
- has only become apparent since source port randomization has become the
- default.
- Thanks to Philip-André Fillion, Phil Sutter, Radoslaw Szkodzinski and
- others for reporting this bug and sending patches.
-
-2009-12-25 Paul Rombouts
-
- * src/status.c,src/status.h,src/pdnsd-ctl/pdnsd-ctl.c
- Add a magic number to pdnsd-ctl command codes to guard against
- possible incompatibility between the pdnsd-ctl utility and the
- pdnsd server.
-
-2009-10-18 Paul Rombouts
-
- * src/dns_query.c
- Make root-server discovery a little more fault tolerant, i.e. if some
- of the root-server names don't resolve don't necessarily reject the
- whole result.
-
-2009-10-17 Paul Rombouts
-
- * src/servers.c,src/dns_query.c,src/dns_query.h
- Implemented automatic root-server discovery, which can now be configured
- by setting "root_server=discover".
-
-2009-06-14 Paul Rombouts
-
- * src/dns_query.c,src/consts.c,src/consts.h,src/conf-parser.c
- Changed the default behaviour of the "neg_rrs_pol" option. The default
- used to be to only cache records negatively in case the AA (authoritive
- answer) bit in the reply was set. The new default is to also allow
- negative caching in case the reply has the RA (recursion available) bit
- set and the query had the RD (recursion desired) bit set.
- This gives the behaviour that is usually wanted in case "proxy_only=on"
- is set without having to set "neg_rrs_pol=on", which can be more
- problematic. The new default can be explicitly set using
- "neg_rrs_pol=default". The values "on","off" and "auth" are also
- still available.
-
-2009-06-13 Paul Rombouts
-
- * src/conff.c,src/conff.h,src/dns_answer.c,src/conf-parser.c,src/conf-keywords.h
- Included a patch contributed by Andreas Steinmetz that implements a new
- global configuration option "ignore_cd". pdnsd used to check that the CD
- bit in the DNS header of queries is zero and return the error code
- "format error" if it is not. However, considering the meaning of this
- bit today it appears to be harmless to ignore it, so the new "ignore_cd"
- is on by default. Setting "ignore_cd=off" gives the earlier strict
- behavior.
- Also renamed the the Z1, AU, Z2 bits to correspond with their modern names
- CD, AD, Z.
-
-2008-12-19 Paul Rombouts
-
- * pdnsd-1.2.7/src/dns_query.c
- If pdnsd receives a SERVFAIL response with a non-empty answer section,
- use the information tentatively if no better response is available.
- The previous behaviour was to discard the reply completely, which could
- cause failure to resolve some names.
- Thanks to Rafal Wijata for providing an example involving PowerDNS servers
- replying with CNAME records.
-
-2008-09-01 Paul Rombouts
-
- * src/dns_query.c
- In p_dns_resolve(), try to reduce the burden on root servers further for
- names ending in "arpa".
-
-2008-08-31 Paul Rombouts
-
- * src/dns_query.c
- In p_exec_query(), if the reply from a remote name server is negative
- (either because the rcode is NXDOMAIN or because the answer section
- contains no records for the queried name), ignore the remaining records
- in the answer section (in particular do not add them to the cache).
-
-2008-07-29 Paul Rombouts
-
- * src/conff.c,src/dns_query.c
- Made the default of the configuration option query_port_start equal to
- 1024. Also improved the algorithm used by pdnsd to select random source
- ports to ensure that each (free) port gets an equal chance of being
- selected. This should guarantee random source ports in the range
- 1024-65535, making pdnsd less vulnerable to some of the issues described
- in CERT VU#800113.
- The old situation, where pdnsd lets the kernel select the source ports,
- is still available by specifying query_port_start=none.
-
-2008-07-25 Paul Rombouts
-
- * src/dns_query.c
- Fixed a dangling pointer bug in p_exec_query(), which could cause pdnsd
- to crash when processing a long reply with many entries in the answer
- section.
-
-2008-05-12 Paul Rombouts
-
- * src/conf-parser.c,src/conff.c
- Added a recursive-depth counter to the read_config_file() and
- confparse() functions to prevent the possibility of infinite
- recursion when processing include files.
- In confparse(), warn when in a server section the root_server option is
- set in combination with policy=simple_only or policy=fqdn_only.
-
-2008-05-10 Paul Rombouts
-
- * src/ipvers.h
- Included a patch contributed by Georg Schwarz which selectively undoes
- a Debian patch contributed by Juliusz Chroboczek on platforms for which
- the IPV6_RECVPKTINFO macro is not defined (e.g. MacOS X).
-
-2008-05-08 Paul Rombouts
-
- * src/status.c,src/pdnsd-ctl/pdnsd-ctl.c
- The pdnsd-ctl add command can now also be used to define NS records.
- A wildcard record defined with this command now behaves the same way as
- one defined in the config file.
-
-2008-05-07 Paul Rombouts
-
- * src/conf-parser.c,src/conf-keywords.h,src/conff.c
- Added the ability to process "include" sections in the configuration
- file. This makes it possible to place local definitions in separate
- files and include them from the main configuration file.
-
-2008-05-05 Paul Rombouts
-
- * src/conff.c,src/conf-parser.c,src/status.c,src/pdnsd-ctl/pdnsd-ctl.c
- Implemented two new pdnsd-ctl commands, which make it easier to add
- definitions to the pdnsd cache at run time. "pdnsd-ctl include" is
- similar to "pdnsd-ctl config" but only processes configuration sections
- that effect the cache and disallows global and server sections.
- "pdnsd-ctl eval" directly parses its string arguments as if they were
- part of a configuration (include) file.
-
-2007-09-15 Paul Rombouts
-
- * src/dns.h,src/dns_answer.c,src/dns_query.c
- Changed the declarations of various packed structs, by moving the
- __attribute__((packed)) specifiers from the field level to the struct level.
- This was necessary to get the correct value for sizeof(rr_hdr_t) when
- compiling with gcc for the ARM architecture.
- Thanks to Dirk Armbrust for reporting the problem and supplying the solution.
-
-2007-08-10 Paul Rombouts
-
- * src/dns_answer.c
- Applied a Debian patch contributed by Juliusz Chroboczek which
- reportedly fixes a problem with pdnsd running in IPv6 mode
- (IPV6_RECVPKTINFO instead of IPV6_PKTINFO).
-
-2007-08-04 Paul Rombouts
-
- * src/dns_query.c
- When resolving a name recursively, pdnsd would stop querying further
- name servers as soon as it received a reply with the authority (aa) flag
- set. Unfortunately, it appears this flag is sometimes raised erroneously
- in replies. I have implemented a work-around that ignores the aa flag
- when there appears to be a clear delegation to a sub-domain.
- Thanks to Nico Erfurth for reporting this problem.
-
- It appears that pdnsd would also fail to consult servers in the authority
- section when configured with neg_rrs_pol=on. This has been fixed.
-
-2007-08-01 Paul Rombouts
-
- * src/pdnsd-ctl/pdnsd-ctl.c
- Made the matching of pdnsd-ctl command names and most of the arguments
- case-insensitive.
-
-2007-07-22 Paul Rombouts
-
- * src/dns_answer.c
- Instead of sharing the responsibility for freeing the answer buffer in
- case of an error amongst different functions, only free it in
- compose_answer().
-
- * configure.in, src/Makefile.am, src/test/Makefile.am
- Merged patch contributed by Pierre Habouzit to deal with CFLAGS the
- automake way (allowing packagers to override CFLAGS properly).
-
-2007-07-21 Paul Rombouts
-
- * src/dns_answer.c
- For each target name in a SRV record in the answer section, add
- addresses to the additional section of the response, as is recommended
- by the RFCs.
-
-2007-07-14 Paul Rombouts
-
- * src/list.c,src/list.h
- Made modifications to the implementation of dynamic arrays, which
- should ensure proper alignment on all supported architectures.
-
-2007-07-10 Paul Rombouts
-
- * Upgraded pdnsd's license to GPL version 3.
-
-2007-07-08 Paul Rombouts
-
- * src/cache.h,src/dns_query.c
- The data field of the rr_bucket_t struct is now aligned such that
- it possible to use straightforward assignment to copy IP addresses,
- making memcpy unnecessary for this purpose.
-
-2007-07-07 Paul Rombouts
-
- * src/dns_query.c
- If pdnsd fails to connect to a name server using a IPv6 address, it will
- now retry the connection using a IPv4 address, if available. This allows
- pdnsd to recover from situations where IPv6 connectivity is temporarily
- unavailable, but IPv4 connectivity still functions.
- Thanks to Andreas Ferber for reporting this problem.
-
-2007-07-04 Paul Rombouts
-
- * src/dns_answer.c
- I have reordered the arguments of the add_rr() and related
- functions to make them more consistent with each other.
-
-2007-07-03 Paul Rombouts
-
- * src/cache.c,src/hash.c
- pdnsd will no longer immediately abort in add_dns_hash() if it fails
- to allocate memory for a new hash entry.
-
-2007-07-01 Paul Rombouts
-
- * src/conff.c,src/conff.h,src/consts.c,src/consts.h,
- src/conf-parser.c,src/conf-keywords.h,src/dns_query.c
- Implemented the new "reject", "reject_policy" and "reject_recursively"
- options for the server section of the configuration file.
-
- * src/ipvers.h,src/conf-parser.c,src/dns.c,src/status.c,
- src/pdnsd-ctl/pdnsd-ctl.c
- Allow local AAAA records to be defined even if pdnsd is compiled
- without --enable-ipv6, provided there is sufficient support in the
- C libraries and --disable-new-rrs was not used.
-
-2007-06-30 Paul Rombouts
-
- * src/dns_answer.c
- Previously, when the answer buffer was realloced in add_rr(), an
- extra 2 bytes used to be reserved, which are unnecessary, as far
- as I can tell. I have decided to do without these extra 2 bytes,
- which originate from Thomas Moestl's code. As compensation, I have
- added extra PDNSD_ASSERT() statements to check that the answer
- buffer does not overflow.
-
-2007-06-27 Paul Rombouts
-
- * src/status.c, src/pdnsd-ctl/pdnsd-ctl.c
- Extended the pdnsd-ctl 'add a' and 'add aaaa' commands to allow
- multiple IP addresses to be specified.
-
-2007-06-25 Paul Rombouts
-
- * src/conff.c,src/conff.h,src/conf-parser.c,src/conf-keywords.h,
- src/dns_query.c
- Implemented a new option for the server section of the configuration
- file: randomize_servers.
-
- * src/servers.c
- Improved the debug messages in uptest().
-
-2007-01-30 Paul Rombouts
-
- * src/icmp.c
- Fixed up the code implementing the ping test in icmp.c,
- which was broken for 64-bit systems.
- Thanks to Michael Uleysky for reporting this bug.
-
-2007-01-09 Paul Rombouts
-
- * src/dns_query.c
- auth_ok() now returns 1 if the cache entry has the DF_NEGATIVE flag set,
- without providing a list of authoritative servers to continue querying.
- Otherwise if we receive a non-authoritative NXDOMAIN reply and pdnsd
- is configured with neg_domain_pol=on, pdnsd will continue to try to
- get an authoritative answer. The intention is that pdnsd
- stops querying as soon as it gets an "unknown domain" answer.
-
-2006-04-29 Paul Rombouts
-
- * src/main.c
- pdnsd would segfault if it tried to call log_message() (via the
- log_warn() and log_error() macros) before the FILE pointer to the debug
- output stream was properly initialized.
- Thanks to Thomas Cort for discovering this problem and suggesting a fix.
-
-2006-04-09 Paul Rombouts
-
- * src/conf-parser.c,src/helpers.c,src/conff.h,src/conff.c
- I have included a patch contributed by Jan-Marek Glogowski, that
- implements the configuration option "use_nss". With use_nss=off pdnsd
- will avoid system functions that may use NSS (i.e. initgroups()), which
- may need DNS for LDAP lookups, which can lead to long timeouts and
- stalls if pdnsd itself is used for the DNS lookup.
-
-2006-03-26 Paul Rombouts
-
- * src/dns_query.c
- Negative caching of RR sets is now also supported with lean_query=off.
-
-2006-03-25 Paul Rombouts
-
- * src/dns_query.c,src/conf-parser.c,src/main.c
- I have implemented a new query method: udp_tcp. With this method a UDP
- query is tried first and, if the UDP answer is truncated, the query is
- repeated using TCP. This is the behaviour that seems to be recommended
- by the DNS standards. However, pdnsd wil not discard the truncated
- answer if the TCP requery fails.
-
-2006-03-24 Paul Rombouts
-
- * src/dns_answer.c
- Previously, pdnsd would add at most one additional A (and AAA) record
- for each record in the answer and authority sections. At the request of
- Angel Marin, pdnsd will now add all A and AAA records it can find in the
- cache for each name that produces additional records.
-
-2006-01-02 Paul Rombouts
-
- * src/dns_answer.c
- compose_answer() would leak memory if the query contained
- an unsupported QTYPE or QCLASS. This has now been fixed.
-
-2005-12-27 Paul Rombouts
-
- * configure.in
- TCP-query support is now compiled in by default.
- It can still be disabled using the configure option
- --disable-tcp-queries.
-
-2005-12-23 Paul Rombouts
-
- * src/dns_answer.c
- Queries received from clients with non-empty answer, authority or
- additional sections are now treated as malformed and rejected with
- rcode 1 (format error).
-
-2005-11-06 Paul Rombouts
-
- * src/conf-parser.c
- Time intervals in the configuration files can now be expressed in
- seconds, minutes, hours, days and weeks, using the suffixes
- s,m,h,d,and w.
-
-2005-10-14 Paul Rombouts
-
- * src/consts.c
- In the pdnsd configuration file, true/false and yes/no are now accepted
- as synonyms for the constants on/off.
-
-2005-08-24 Paul Rombouts
-
- * src/helpers.c
- I have fixed a potential buffer overflow problem that could occur with
- the 'pdnsd-ctl dump' command.
- In case of the root domain, the function rhn2str() would write 2 bytes
- to the output buffer even if size==1. Theoretically (under pathological
- circumstances) this could have allowed the dbuf buffer in the function
- dump_cent() to overflow by one byte.
-
-2005-08-21 Paul Rombouts
-
- * acconfig.h,src/cache.c,src/conff.c,src/conf-parser.c,src/dns.c,
- src/dns_answer.c,src/dns_query.c,src/error.h,src/helpers.c,src/main.c,
- status.c
-
- It appears the newer versions of gcc won't convert a pointer to char
- into a pointer to unsigned char and vice versa without complaining.
- The changes I have made should get rid of these distracting warning
- messages. Unfortunately I had to introduce casts in some cases,
- which reduces type safety :-(.
-
-2005-08-16 Paul Rombouts
-
- * src/dns.h
- Some changes were made to the endianess detection code to
- address problems on Mac OS X v10.4 Tiger.
-
-2005-08-15 Paul Rombouts
-
- * configure.in
- Some changes where made to address the reported problems with the
- configure script on Mac OS X v10.4 Tiger.
-
-2005-08-05 Paul Rombouts
-
- * src/status.c,src/dns_answer.c
- The output of the 'pdnsd-ctl status' command now includes some
- statistics on the number of query threads.
-
-2005-07-29 Paul Rombouts
-
- * src/main.c
- It appears that sigwait() can return EINTR under certain conditions.
- This explains the problems reported by Sanjoy Mahajan with strace
- and ACPI S3 sleep, which both caused pdnsd to exit prematurely.
- The return value of sigwait() is now checked and sigwait() is retried
- if the return value is EINTR.
-
-2005-07-04 Paul Rombouts
-
- * src/dns_query.c
- It appears that some servers that do not support recursive queries
- answer with "query refused" instead of "not supported". The
- p_exec_query() function now takes that possibility into account.
-
-2005-07-01 Paul Rombouts
-
- * src/dns_query.c
- In the processing of queries, I will make a distinction between
- recoverable errors and non-recoverable ones (typically caused by out of
- memory conditions). In the case of non-recoverable errors, no attempt to
- query alternative name servers is made.
-
-2005-06-26 Paul Rombouts
-
- * src/dns_query.c
- In p_recursive_query(), as soon as one of the servers in the q list
- replied "no error" or "name error", only this reply was examined and
- the other servers in the q list were ignored. Joshua Coombs has brought
- to my attention that this strategy sometimes fails when this reply is not
- authoritative and doesn't contain any usable references to name servers
- in the authority section.
- I have modified p_recursive_query() to allow pdnsd to continue querying
- the remaining servers in the q list as long as we haven't received an
- authoritative answer or usable authority information. This will allow
- pdnsd to arrive at the correct answer in some cases where it would
- formerly fail.
-
-2005-06-25 Paul Rombouts
-
- * src/status.c
- The "pdnsd dump" command may now also be given an argument
- consisting of a name beginning with a dot. This will dump information
- about all names in the cache ending in the given name. An argument
- consisting of a name without a leading dot will only give information
- about the exact name, as it did before.
-
-2005-06-24 Paul Rombouts
-
- * src/servers.c,src/status.c
- All uptests are now conducted by the server status thread. If a retest
- is requested via a "pdnsd-ctl server", an existing server status thread
- is signaled or a new server status thread is spawned if the old one has
- exited. This has the effect that a "pdnsd-ctl server label retest"
- command will now return immediately without waiting for the tests to
- finish.
-
-2005-06-20 Paul Rombouts
-
- * src/conf-parser.c,src/servers.c,src/servers.h
- At the request of Al-Junaid Walker I have added a new configuration
- option for the uptest interval. With "interval=ontimeout" the server is
- not tested at startup/reconfig, or at regular intervals, but only after
- a DNS query to a server times out. However, once a server is declared
- dead it is never considered again unless it is revived using a
- "pdnsd-ctl config" or "pdnsd-ctl server" command.
-
-2005-06-19 Paul Rombouts
-
- * src/servers.c,src/dns_query.c,src/icmp.c
- During an uptest the server configuration data is locked. Especially
- with ping or query uptests of unresponsive servers this means that the
- execution of "pdnsd-ctl config" or "pdnsd-ctl server" commands can be
- delayed for a long time (or even time out). I have made modifications
- that allow a "pdnsd-ctl config" or "pdnsd-ctl server" commands to
- interrupt pending uptests to allow these commands to proceed without
- delay in most cases.
-
- * src/thread.h
- Use the POSIX sigaction() instead of signal() to install signal handlers.
-
-2005-06-08 Paul Rombouts
-
- * src/dns_answer.c,src/dns_query.c
- I have defined a struct dns_msg_t that includes a message length field.
- In the case of sending a DNS message over TCP, we no longer need a
- separate write() call to send the message length. This prevents possible
- packet fragmentation.
-
-2005-06-07 Paul Rombouts
-
- * src/dns_query.c
- The query_method=tcp_udp option only used to work with cooperative name
- servers, i.e. servers that either send back a TCP reply or explicitly
- refuse the TCP connection request. This wasn't sufficiently satisfactory
- in practice, because some name servers are completely unresponsive to TCP
- connection requests. I have made modifications to allow pdnsd to try UDP
- queries in case TCP connections time out. When a short server timeout is
- combined with a global timeout that is at least twice as long, this may
- allow a query to a name server that only responds to UDP queries to
- succeed with query_method=tcp_udp.
-
-2005-04-20 Paul Rombouts
-
- * src/cache.c,src/hash.c,src/conff.c,src/status.c,src/pdnsd-ctl/pdnsd-ctl.c
- The "pdnsd-ctl empty-cache" command now accepts additional arguments;
- these are interpreted as include/exclude names. During execution of the
- command the name of each cache entry is matched against the names in the
- include/exclude list. If the name ends in a name to be included, the
- cache entry is deleted, otherwise not.
- This feature was added at the request of Joshua Coombs.
-
-2005-04-19 Paul Rombouts
-
- * src/cache.c, src/hash.c
- pdnsd will now (temporarily) unlock the cache between emptying hash
- buckets, this should allow pdnsd to remain responsive while executing
- the "pdnsd-ctl empty-cache" command. However, this only applies to DNS
- queries; pdnsd will not accept any new pdnsd-ctl commands while a
- pdnsd-ctl command is still running.
-
-2005-03-29 Paul Rombouts
-
- * configure.in, src/hash.h
- I have added a new configure option --with-hash-buckets=...
- This makes it possible to specify a different number of
- hash buckets without editing the source files.
-
-2005-03-17 Paul Rombouts
-
- * src/error.c
- When running in both daemon and debug mode, print warning and
- error messages to debug file as well as the syslog.
-
-2005-03-15 Paul Rombouts
-
- * src/dns_answer.c
- Only call pthread_setspecific() in debug mode, because
- pthread_getspecific() is also only used in debug mode.
- If pthread_setspecific() fails, treat this as a non-fatal error.
-
-2005-03-10 Paul Rombouts
-
- * configure.in
- On Linux systems the configure script will now try to detect automatically
- whether the system implements the Native POSIX Thread Library, but
- the method is not necessarily foolproof.
-
- * src/dns.c
- Local PTR records generated for resolving numeric IPv6 addresses back into
- names, are now based on ip6.arpa instead of ip6.int, because the latter domain
- will be phased out eventually.
-
-2005-03-06 Paul Rombouts
-
- * Makefile.am,src/cache.c
- Create an empty cache-file at install time and don't complain about empty
- cache files at start up.
-
-2005-02-20 Paul Rombouts
-
- * acconfig.h,configure.in,src/conf-parser.c,src/conff.h,src/dns.h,
- src/dns_answer.c,src/dns_query.c,src/error.h,src/helpers.h,src/icmp.c,
- src/ipvers.h
-
- I have applied some changes to the code proposed by Rodney Brown to improve
- portability. In particular, pdnsd should now compile on the Darwin platform
- (Apple Mac OS X).
- To support some of these changes, the source package is now built with a
- slightly more modern version of autoconf (2.57) and automake (1.6.3).
-
-2005-01-29 Paul Rombouts
-
- * src/dns.c,src/dns_answer.c,src/dns_query.c
-
- I have added some extra debug code to make it easier to discover the
- reason that pdnsd considers a query or reply malformed (format error).
-
-2005-01-12 Paul Rombouts
-
- * src/dns.c,src/dns_answer.c,src/dns_query.c
-
- I have extended some debug code contributed by Kiyo Kelvin Lee to dump
- the data received by pdnsd in debug mode (queries from clients, replies
- from name servers). Because this will give very verbose debug output,
- I've arranged it so that this data dump only occurs if pdnsd has been
- configured and compiled with --with-debug=9 and pdnsd has been called
- with -v9.
-
- Additionally, in the case that pdnsd rejects a reply from a name server
- because it is not well formed, I have refined the debug messages to
- distinguish between format errors due to unexpected truncation and
- others kinds of format errors.
-
-2004-10-30 Paul Rombouts
-
- * src/rr_types.c
- I have included some changes proposed by Joseph Pecquet to address
- the compilation problems reported by FreeBSD users.
-
-2004-10-18 Paul Rombouts
-
- * acconfig.h,configure.in,src/helpers.c,src/helpers.h,src/dns.h
- I have merged a patch for CYGWIN support by Kiyo Kelvin Lee into
- my version of the code.
-
-2004-10-15 Paul Rombouts
-
- * src/cache.c
- Invalidating local records with the pdnsd-ctl did not work the way the
- documentation described. An invalidated local record would be always be
- purged at the next lookup, thus invalidation would practically have the
- same effect as deletion. An invalidated local record is of no use at all and
- would occupy space until it is purged during a lookup (but not by purge_cache).
- The function invalidate_record() now behaves as the documentation describes, i.e.
- invalidation of local records has no effect.
-
-2004-09-27 Paul Rombouts
-
- * doc/pdnsd.conf.5.in
- A new man page describing the format of the pdnsd config file has been
- added to the pdnsd package. I've used a customized Perl script to generate
- one automatically from the html documentation.
-
-2004-09-14 Paul Rombouts
-
- * src/hash.c
- The cache entries in a hash chain are now stored in order of increasing long hash
- value. The advantage is that if an name is looked up that is not present in the
- cache, this can be done by comparing with only half (on average) of the number
- of entries in the hash chain. Not a huge speed up, but still worth while, I think.
- Additionally, the number of hash computations for each add_cache() call has
- been halved.
-
-2004-09-11 Paul Rombouts
-
- * src/cache.c
- insert_rrl() will no longer add local records to the rr_l list, because
- purge_cache() ignores them anyway.
-
-2004-09-08 Paul Rombouts
-
- * src/dns.h,src/cache.c,src/dns_query.c,src/dns_answer.c,src/conf-parser.c
- I've started using GETINT16,GETINT32,PUTINT16,PUTINT32 macros, which are based
- on the NS_GET/NS_PUT macros that can be found in the BIND source, instead of memcpy
- for fetching and storing non-aligned integer data.
-
-2004-09-08 Paul Rombouts
-
- * src/cache.c,src/status.c,src/pdnsd-ctl/pdnsd-ctl.c
- New pdnsd-ctl command: "pdnsd-ctl dump" will print information about all the
- entries contained in the cache.
- "pdnsd-ctl dump " will only print entries belonging to .
- The data fields of the more common rr-types will be printed in human readable
- form, the remaining ones in a hexadecimal representation.
- With thanks to Dan Jacobson for suggesting this feature.
-
-2004-08-31 Paul Rombouts
-
- * src/conf-parser.c
- At the suggestion of Dan Tihelka, I have expanded to the server_ip= option
- to allow the name of an interface to be specified instead of an IP address.
- pdnsd will not bind to the interface name, but will lookup the address the
- interface has at start up, and listen on that address. If the address
- of the interface changes while pdnsd is running, pdnsd will not notice that.
-
-2004-08-30 Paul Rombouts
-
- * src/cache.h,src/cache.c
- I've reversed the meaning of the CF_NOAUTH and renamed it CF_AUTH.
- I've also added a domain level flag DF_AUTH, which is used to
- mark cache entries obtained from authoritave replies in response to
- a query of type * (all)..
-
-2004-08-30 Paul Rombouts
-
- * src/cache.c
- I've changed the format of the cache file. A typical cache entry has empty
- sets for most RR types (even more if DNS_NEW_RRS is defined). In the old
- format, each empty RR set was represented by a zero byte.
- In the new format only non-empty sets are respresented, leading
- to a (modest) reduction is size.
-
-2004-08-28 Paul Rombouts
-
- * src/conf-parser.c
- New option for "rr" sections in the config file: reverse=on/off.
- If you want a locally defined name to resolve to a numeric address and vice
- versa, you can now achieve this by setting reverse=on before defining the
- A record, making it unnecessary to define a seperate PTR record for the reverse
- resolving.
-
-2004-08-20 Paul Rombouts
-
- * src/cache.h,src/cache.c,src/conf-parser.c,src/dns_query.c
- At the request of Daniel Black, I have added support for defining local wildcard records
- in pdnsd. The only type supported presently is records beginning with '*.'.
-
-2004-08-10 Paul Rombouts
-
- * src/hash.c,src/cache.c,src/dns_query.c,src/dns_answer.c
- Sampo Lehtinen has remarked that pdnsd sometimes failed to resolve classless
- reversed-delegated IP addresses, and that this has something to do with the fact
- that pdnsd did not accept '/' characters in domain names. After reading Sampo's
- and Thomas' remarks, and also rfc2317 and some of the rfc's referenced in rfc2317,
- I decided pdnsd should place no restrictions at all on the types of characters it
- allows in domain names, only on the lengths of the byte sequences.
- This led me to make some quite extensive internal changes to pdnsd. Among other
- things domain names are now stored in transport format (sequences of bytes preceded
- by length bytes) instead of C strings. This is also more efficient because there
- is no need any more to convert from one representation to the other, except when
- reading the config file, interacting with pdnsd-ctl or running in debug mode.
- Conversion between the two representations isn't always possible, though.
- For example, domain names in transport format might contain non-printable characters.
- These are now printed as escape sequences (three octal digits preceded by a back slash).
- Presently there are still restrictions on the characters in the domain names that can
- be defined in local records. I doubt this will ever be considered a problem.
-
-2004-08-02 Paul Rombouts
-
- * src/dns_query.c
- The code for handling NXT records was flawed. A response from a remote server
- containing NXT records (even well-formed ones) could cause pdnsd to crash.
- The code for handling NAPTR records contained incorrect PDNSD_ASSERT statements,
- which could cause pdnsd to abort unnecessarily.
-
-2004-07-25 Paul A. Rombouts
-
- * src/list.h,src/list.c,src/dns.c,src/dns_query,src/dns_answer.c
- I've noticed that some of the (dynamic) arrays that pdnsd uses are quite sparse.
- Instead of using an array structure with elements that are large enough to contain
- the largest possible domain name, I've implemented a "list" data structure that
- is more compact. The elements of a list can only be accessed sequentially from
- beginning to end, but it allows more efficient memory use in case the names are
- significantly shorter that the maximum.
-
-2004-07-22 Paul Rombouts
-
- * src/conf-parser.c
- I've expanded pdnsd's configuration options by adding support in pdnsd for reading
- /etc/resolv.conf style files. Instead of specifying IP addresses in a server section,
- the option "file=" can be used.
- The IP addresses in the lines beginning with "nameserver" will be added to
- the list of address for that section, the remaining lines will be ignored.
- To avoid the possibility that pdnsd will query itself, local addresses are skipped
- (unless pdnsd is configured to listen on a different port number).
-
-2004-07-21 Paul Rombouts
-
- * src/cache.h,src/cache.c,src/dns_query.c,src/conf-parser.c
- New option for "server" sections in the config file: root_server=on/off.
- In case a server section contains only addresses of root servers, which
- usually only give the nameservers of top level domains in their reply,
- setting root_server=on will enable certain optimizations. This involves using
- cached information to reduce queries to the root servers, thus speeding up
- the resolving of new names. This option is also necessary to make the
- delegation_only option work in combination with root servers.
-
-2004-07-16 Paul Rombouts
-
- * src/cache.c,src/status.c,src/pdnsd-ctl/pdnsd-ctl.c
- New pdnsd-ctl command: "pdnsd-ctl empty-cache" will make pdnsd delete its entire
- cache, freeing all entries. This is useful for debugging purposes, or in situations
- where you suspect that stale cache entries are causing you problems, but you are not
- sure which ones.
-
-2004-07-11 Paul Rombouts
-
- * src/cache.c,src/dns_query.c
- I've removed the use of the function add_cache_rr_add(), which was used to
- add additional RR records to the cache one at a time. I've changed the code
- in dns_query.c such that additional (or off-topic) records are first collected
- in arrays of dns_cent_t structures, and then added to the cache using add_cache().
- With this approach only one function, viz. add_cache(), is used for adding
- new entries to the cache, which I believe leads to a cleaner programming
- interface. Added benefit is that query serial numbers are no longer
- necessary.
-
-2004-07-10 Paul Rombouts
-
- * src/cache.h,src/cache.c,src/dns_query.c,src/dns_answer.c
- I've added two new field to the dns_cent_t struct, namely c_ns and c_soa.
- These will be used to remember references to NS and SOA records in the authority
- sections of replies from remote name servers.
- This information can be used by pdnsd to fill in the authority section of its
- own reply.
-
-2004-06-25 Paul Rombouts
-
- * src/dns_query.c,src/servers.c,src/consts.c
- I've added an new server availability test which can be selected with "uptest=query".
- This can be useful as an alternative to "uptest=ping" in case the remote server does not
- respond to ICMP_ECHO requests at all, which unfortunately is quite common these days.
- "uptest=query" causes pdnsd to send an empty query to remote nameservers. Any well-formed
- response (apart from SERVFAIL) within the timeout period will be interpreted as a sign that the
- server is "up".
- In a sense this new availability test can actually be considered more reliable than the
- other ones that pdnsd supports.
- With thanks to Juliusz Chroboczek for suggesting this feature.
-
-2004-06-24 Paul Rombouts
-
- * src/helpers.c
- Don't use getpwnam() while we are multi-threaded, because it returns a pointer to
- a statically allocated structure. I will use getpwnam_r() instead, which is thread
- safe. Unfortunately there seem to be some portability problems with getpwnam_r().
- For those platforms that lack getpwnam_r(), I will keep the old code with getpwnam()
- as an alternative.
-
-2004-06-23 Paul Rombouts
-
- * src/servers.c
- Check that the number of IP addresses in a server section is nonzero before
- testing servers for availability. Otherwise pdnsd could crash in debug mode.
-
-2004-06-21 Paul Rombouts
-
- * src/conff.c,src/conf-parser.c,src/status.c,src/pdnsd-ctl/pdnsd-ctl.c
- New pdnsd-ctl command: "pdnsd-ctl config" will make pdnsd re-load its configuration file.
- In most cases (but there are still some exceptions) this is preferable
- to restarting pdnsd after making changes to the configuration file.
- An important advantage is that there should be no perceptible interruption in the dns service
- when using the reload command.
- An alternative config file can be specified with "pdnsd-ctl config ".
-
-2004-05-31 Paul Rombouts
-
- * src/dns_answer.c,src/dns_query.c,src/dns_query.h
- I've made an adjustment to p_recursive_query() and related functions, so that
- when pdnsd chases name servers in pursuit of authoritative records, it avoids
- all the name servers already queried for the same name in the recursive calling
- chain, not just the servers most recently used.
- Although the hops counter will already break any possible cycles, this will
- allow pdnsd to detect pathological cycles earlier and waste less resources.
-
- * src/cache.c
- In add_cache(), don't add empty entries to the cache. Empty cache entries
- waste memory and are more persistent than non-empty ones, because purge_cache()
- cannot get rid of them.
-
-2004-05-30 Paul Rombouts
-
- * src/dns_answer.c,src/dns_query.c,src/icmp.c,src/netdev.c
- I've removed the calls to getprotobyname() and used the constants IPPROTO_TCP
- and IPPROTO_UDP instead. First of all, it doesn't seem very efficient to call
- a function repeatedly to look up the same well-known protocol numbers.
- More importantly, getprotobyname() stores its results in a statically-allocated
- structure and thus cannot be considered thread safe. (getprotobyname_r()
- is thread safe, but is not portable.)
-
-2004-05-27 Paul Rombouts
-
- * src/dns_answer.c
- I've noticed that when pdnsd is restarted shortly after it has answered a TCP
- query, it is often not able to bind to the TCP socket again, resulting in a
- disabled TCP server thread. The solution appears to be to set the SO_REUSEADDR
- socket option before binding the socket. This allows you to use the same port even
- if it is busy (in the TIME_WAIT state).
- I found the code for this in a patch file from an old Debian package.
-
-2004-05-20 Paul Rombouts
-
- * src/dns_query.c
- Joseph Pecquet has reported that version 1.1.11 does not compile under FreeBSD v4.x
- because the macro ENONET is undefined. I've bypassed the problem by surrounding
- the case line using this value with conditional preprocessor directives.
-
-2004-05-08 Paul Rombouts
-
- * src/rc/Slackware/rc.pdnsd
- I've included a Slackware start-up script contributed by Nikola Kotur.
-
-2004-05-05 Paul Rombouts
-
- * doc/pdnsd.8
- I'm very grateful to Mahesh T. Pai for contributing a pdnsd man page,
- which was still missing up till now.
-
-2004-04-30 Paul Rombouts
-
- * src/servers.c,src/dns_query.c
- After considering some suggestions made by Juliusz Chroboczek I have made the
- following changes:
-
- - After receiving a reply from a remote server mark the server up and update the
- timestamp so that pdnsd doesn't bother testing this server for availability for a
- while.
- - After detecting an error with an send/recv call that indicates a server is
- unavailable, mark a server down so that pdnsd doesn't bother testing this server
- for a while.
- - After server timeouts, uptests are never performed by a query/answer thread,
- because this may delay the sending of an answer to the client. Instead the
- timestamp of a server that needs to be tested for availability is set to zero and
- a condition signal is sent to alert the server status thread, which will carry out
- the test. Unresponsive servers with uptest=ping will not be marked down
- immediately any more, but only after the ping test has definitely failed.
-
- * src/error.c,src/error.h
- I've moved most of the code previously contained in the DEBUG_MSG macro to a new
- function debug_msg().
- The DEBUG_MSG macro now simply expands to "if(debug_p) debug_msg();".
- This should make the executable a little smaller, and be just as fast when
- debugging is off. The DEBUG_MSG macro still expands to nothing if pdnsd is built
- without debugging support.
-
-2004-04-28 Paul Rombouts
-
- * src/dns_query.h,src/dns_query.c
- I've tried to simplify the finite state machine used for processing parallel
- queries, by merging the "state" and "nstate" variables used by p_exec_query() and
- p_query_sm() resp. into one "state" variable.
- By introducing an extra field "iolen" to keep track of the number of bytes read
- from or written to a socket, I could also reduce the number of states for TCP
- queries. The new code has the additional advantage that it can handle situations
- that require multiple read() calls to receive a response.
-
-2004-04-14 Paul Rombouts
-
- * src/dns_query.c
- I've added an extra check comparing the number if poll/select events actually
- handled to the return value of poll/select. This should reduce the chance that
- pdnsd will get caught in a busy spin due to unknown remaining bugs. An error
- message is logged and an error code is returned when this comparison fails.
-
-2004-04-13 Paul Rombouts
-
- * src/dns_query.h,src/dns_query.c
- I got rid of the event field in the query_stat_t struct.
- I think it is redundant, because its value can be quite simply derived from
- the nstate field.
-
-2004-04-12 Paul Rombouts
-
- * src/dns_query.c
- I appears there was flaw in the code for handling a "Not Implemented" response
- from a remote server with the RA (recursion available) bit equal to zero. This
- could cause pdnsd to get into a busy spin. I traced the flaw back to Thomas
- Moestl's code, so it must be in all the versions of pdnsd I know of. In previous
- versions of pdnsd the busy spin would eventually time out. Due to some recent
- changes the loop would no longer time out, making the bug more noticeable.
- With thanks to Nicolas George for reporting the bug.
-
- I also discovered a closely related flaw that would cause pdnsd to poll() closed
- file descriptors. It usually works out OK in practice, but it is definitively not
- the correct way to do it.
-
- Additionally, I discovered some opportunities to save memory, e.g. by replacing
- the nsname buffer in the query_stat_t struct by a pointer to an already existing
- copy of a name.
-
-2004-04-10 Paul Rombouts
-
- * src/cache.c
- Nicolas George remarked that he thought it was strange that subdomains of domains
- negated with "neg" sections in the config file were not also negated. I thought that
- he had a point, and I've implemented a change so that negating example.com will
- now also negate www.example.com, xxx.adserver.example.com, etc.
-
-2004-04-09 Paul Rombouts
-
- * src/error.c,src/error.h
- I noticed that the code for the log_warn() and log_error() functions was almost
- identical, even to the point that log_warn() called syslog() with LOG_ERR
- priority. I've merged these two functions into one log_message() function.
-
-2004-04-08 Paul Rombouts
-
- * src/main.c,src/conf-parser.c
- The -4 and -6 command-line options should now work as advertised.
- This wasn't entirely trivial. The rule is that options on the command line
- override those in the configuration file. The easiest way to implement this is to
- process the command-line options after reading the configuration file. But this
- doesn't work for the -4 and -6 options, because the run_ipv4 flag determines how
- IP addresses in the config file are parsed. I've inserted some extra tests and
- warning messages that will hopefully make this setting nearly foolproof.
-
- I've added two new command-line options, "-a" and "-i ".
- With the -a flag pdnsd will try to detect automatically if IPv6 support is
- available on a system, and fall back to IPv4 if not. The -a flag can be used
- instead of -4 or -6.
-
- In IPv6 mode, pdnsd will now automatically convert IPv4 addresses to IPv6-mapped
- addresses. The -i option can be used to specify a prefix for this mapping. The
- default is ::ffff.0.0.0.0
- There is also a corresponding ipv4_6_prefix= option for the config file.
-
- In IPv4 mode, if IPv6 support is compiled in, pdnsd will now skip IPv6 addresses
- in the config file (except for the server_ip and ping_ip options) with a warning
- message. This allows you to have mixed sets of IPv4 and IPv6 address in the same
- config file, although in IPv4 mode some server sections may become inactive.
-
- With thanks to Juliusz Chroboczek for suggesting these changes.
-
-2004-04-07 Paul Rombouts
-
- * src/cache.c
- I've changed some of the cache-flag definitions to make debugging a little simpler.
- Unfortunately, this makes the cache files of previous pdnsd versions incompatible
- with the new one. I've introduced a cache version identifier to be added at the
- beginning of each cache file. This enables pdnsd to recognize and discard
- incompatible cache files.
-
-2004-04-05 Paul Rombouts
-
- * src/cache.h,src/cache.c
- I've changed the way CACHE_LAT (cache latency, normally 120 secs) is used to
- determine whether a cache entry has timed out. Instead of simply adding it to the
- ttl (time to live), I use CACHE_LAT if the ttl is less then CACHE_LAT, else the
- ttl itself, making CACHE_LAT the minimum ammount of time a cache entry stays in
- the cache.
-
-2004-04-02 Paul Rombouts
-
- * src/dns_query.c
- I've introduced a global timeout parameter. This is the minimum period of time
- pdnsd will wait after sending the first query to a remote server before giving
- up without having received a reply.
- The timeout options in the configuration file are now only minimum timeout intervals.
- Setting the global timeout option makes it possible to specify quite short timeout
- intervals in the server sections. This will have the effect that pdnsd will start
- querying additional servers fairly quickly if the first servers are slow to respond
- (but will still continue to listen for responses from the first ones).
- This may allow pdnsd to get an answer more quickly in certain situations.
-
- * src/dns_query.c
- When receiving a NXDOMAIN (unknown domain) response from a remote name server,
- I think it is still useful to process the authority and additional sections,
- so that pdnsd can possibly add a SOA record to its own response.
-
-2004-04-01 Paul Rombouts
-
- * src/dns_query.c
- In p_recursive_query(), I've slightly changed the way pdnsd does parallel
- queries. Active queries or not canceled until we have received a useful response
- from a remote name server, or all the queries have failed or timed out.
- Thus the par_queries parameter is no longer the maximum number of parallel
- queries, but rather the increment with which the number of parallel queries is
- increased when the previous set has timed out.
- In the worst case all the servers in the list of available servers will be queried
- simultaneously. We may be wasting more system resources this way, but the advantage
- is that we have a greater chance of catching a reply.
- After all, if we wait longer anyway, why not for more servers.
-
-2004-03-31 Paul Rombouts
-
- * src/dns_answer.c
- I've noticed that in compose_answer() that while adding the name in the query
- section it was not passed through compress_name(). While it is true that the
- first name occurrence cannot be compressed, it is still sensible to process the
- query name with compress_name() so that the offset can be stored and provide
- additional opportunities for future compressions.
- I've tested this with dig and the responses of pdnsd are now usually a little
- smaller in size or can hold more information within the 512 byte limit.
-
-2004-03-30 Paul Rombouts
-
- * src/cache.c
- I've noticed that pdnsd stored rr records (of the same type) in reverse order
- in the cache.
- Although I don't see anything inherently wrong with that, I think it's neater to
- store them in the order they are processed.
-
-2004-03-29 Paul Rombouts
-
- * src/cache.c
- I've rearranged the order of the arguments of some of the functions in cache.c
- to obtain a more consistent calling interface.
-
- * src/dns_answer.c
- I've noticed that pdnsd would only add NS records to an authority section if it could
- find such records matching the queried name (or the last CNAME in the answer) exactly.
- However, I understand that a server should try to give NS records as close as possible
- to the target name in the naming hierarchy.
- I also understand that if a domain name is reported as nonexisting, or no record of
- the requested type exists, it is customary to provide a SOA record, searching up the
- name hierarchy if necessary.
- I've tried to implement this in compose_answer(), although with some limitations.
- I only look in the cache, I don't search more then three levels up, and stop before
- the top level.
-
-2004-03-28 Paul Rombouts
-
- * src/cache.c,src/dns_answer.c
- There were some issues with add_cache_rr_add().
-
- First of all, the way it was used in rr_to_cache() (or rather not used) meant
- that if an "off topic" record was added for a name that lacked an entry in the
- cache, the rr set would be created with an incorrect serial number (namely zero).
- I've rewritten add_cache_rr_add so that it can create new cache entries if necessary.
- This simplifies the code in rr_to_cache() and ensures correct serial numbers.
-
- Secondly, in add_cache_rr_add() the ttl was compared with that of an existing rrset
- without adjusting for the min_ttl and max_ttl options. This could lead to all the
- previous records being deleted, retaining only the last one.
-
-2004-03-27 Paul Rombouts
-
- * src/dns_answer.c
- In compose_answer(), if the rd (recursion desired) bit is set in the query
- and the response contains a CNAME record (while a different type of record was
- requested), always do a recursive query on the CNAME, even if we have already
- added a record of the requested type to the response.
- Failing to honor the rd bit will cause some resolver libraries to complain,
- even if the answer contains a record of the requested type.
-
- I've slightly changed the calling interfaces of add_to_response() and add_rrset()
- to make them more consistent and efficient.
-
- In add_rrset() I've fixed a memory leak on one of the error paths.
-
- In add_additional_rr(), the return value of add_rr() was not checked.
- If add_rr() fails, it will free *ans, and functions higher up the calling
- chain could be referencing freed memory.
-
- I've fixed a potential referencing of freed memory or double freeing in add_additional_a().
- If a call of add_additional_rr() fails, it will free *ans.
- Previously, add_additional_rr() could be called a second time, in which case
- the second call would be referencing freed memory or freeing it a second time..
-
-2004-03-23 Paul Rombouts
-
- * configure.in, src/Makefile.in,src/pdnsd-ctl/Makefile.in,src/test/Makefile.in
- Frédéric L. W. Meunier has reported that configure --srcdir option (for building
- in directory separate from the source directory) was broken.
- Should be fixed now.
-
-2004-03-20 Paul Rombouts
-
- * src/dns_answer.c,src/dns_query.c,src/helpers.c,src/icmp.c,src/main.c,src/netdev.c,src/ipvers.h,src/test/if_up.c,src/test/is_local_addr.c,src/test/tping.c,src/test/random.c,src/conf-parser.c
- I've eliminated the global variable run_ipv6 from the code.
- Enabling both the IPv4 and IPv6 protocols at the same time is not supported
- in pdnsd, so the value of run_ipv6 (if it is defined) is simply !run_ipv4.
-
- * src/dns.c,src/test/is_local_addr.c,src/test/tping.c
- It appears the option to compile pdnsd without IPv4 support (i.e. only IPv6
- support) was broken. Should be fixed now.
-
-2004-03-19 Paul Rombouts
-
- * src/cache.c
- I've discovered an incorrect use of cache locks in lookup_cache().
- We only read locks in place, it is possible for purge_cent() to delete a cache
- entry while another thread is trying to read it at the same time, which could
- lead to trouble. I've rewritten purge_cent() so that it can be used to test
- whether something needs to be purged without actually deleting anything.
- If something needs to be deleted, purge_cent() will be called again with
- the proper read/write locks in place, excluding access to the cache for all
- other threads.
-
-2004-03-18 Paul Rombouts
-
- * src/cache.c
- I've added a new function sort_rrl() for sorting the rr_l list using a merge-sort
- algorithm. Usually the insertion sort used by insert_rrl() is good enough, because
- new entries belong near the end most of the time. Reading entries from disk forms
- an exception, though, because the rrsets in the file are completely out of order
- w.r.t. timestamps, leading to quadratic time complexity of the insertion sort method.
- In that case it should be faster to simply append items at the end of the rr_l list
- and sort using a more efficient algorithm afterwords.
- pdnsd now seems to start up noticeably faster when reading large cache files.
- I've also considered using a more sophisticated data structure than a doubly linked
- list, but this will add considerable complexity to the code and use more memory.
-
-2004-03-13 Paul Rombouts
-
- * src/dns_answer.c
- Changed a declaration in udp_answer_thread() so that the buffer used for passing
- control messages on to sendmsg() is exactly the right size, instead of an arbitrary
- 512 bytes.
- Also initialized the msg_flags of the struct msghdr passed on to sendmsg() to zero,
- to keep Valgrind from complaining about uninitialized bytes.
-
-2004-03-12 Paul Rombouts
-
- * src/icmp.c
- Fixed an incorrect call to select() in ping4(). A file descriptor set for detecting
- exceptions was initialized but not passed on to select(). This would lead subsequent
- code always to behave as if an IO exception had occurred.
- Valgrind seems to indicate that when a poll() call times out and returns 0,
- the revents field of the struct pollfd is not necessarily set.
- I've changed the code to check that the return value is > 0 before examining the
- revents field.
-
-2004-02-06 Paul Rombouts
-
- * src/conf-parser.c,src/conf-parser.h,src/conf-keywords.h
- I've rewritten the parser for the configuration file in C from scratch.
- (f)lex and yacc/bison are no longer needed to build pdnsd.
-
-2004-01-16 Paul Rombouts
-
- * src/main.c
- Load the cache from disk without locking cache access because pdnsd
- is still single-threaded at that point.
-
-2004-01-15 Paul Rombouts
-
- * src/cache.c,src/hash.c
- Moved the responsibility for freeing the cache entries referred by
- the hash buckets from destroy_cache() to free_dns_hash() (which is called
- by destroy_cache()). Previously, the cache and hash tables were already
- completely destroyed by the time free_dns_hash() was called, and there was
- nothing left for free_dns_hash() to free.
-
-2004-01-14 Paul Rombouts
-
- * src/hash.c,src/make_hashconvtable.c
- The hash conversion table is now generated at build time instead
- of at run time when pdnsd is started up.
-
-2004-01-13 Paul Rombouts