Skip to content
GitLab
About GitLab
GitLab: the DevOps platform
Explore GitLab
Install GitLab
How GitLab compares
Get started
GitLab docs
GitLab Learn
Pricing
Talk to an expert
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Projects
Groups
Snippets
Sign up now
Login
Sign in / Register
Toggle navigation
Menu
Open sidebar
Imre Kristoffer Eilertsen
DnsChanger
Commits
8d321f6c
Commit
8d321f6c
authored
Apr 18, 2018
by
Daniel Wolf
Browse files
Added new Entity DNSTLSConfiguration
parent
74ce4155
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/com/frostnerd/dnschanger/database/DatabaseHelper.java
View file @
8d321f6c
package
com.frostnerd.dnschanger.database
;
import
android.content.Context
;
import
android.database.Cursor
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
...
...
@@ -10,11 +9,13 @@ import com.frostnerd.dnschanger.database.entities.DNSEntry;
import
com.frostnerd.dnschanger.database.entities.DNSQuery
;
import
com.frostnerd.dnschanger.database.entities.DNSRule
;
import
com.frostnerd.dnschanger.database.entities.DNSRuleImport
;
import
com.frostnerd.dnschanger.database.entities.DNSTLSConfiguration
;
import
com.frostnerd.dnschanger.database.entities.IPPortPair
;
import
com.frostnerd.dnschanger.database.entities.Shortcut
;
import
com.frostnerd.utils.database.CursorWithDefaults
;
import
com.frostnerd.utils.database.orm.Entity
;
import
com.frostnerd.utils.database.orm.parser.ParsedEntity
;
import
com.frostnerd.utils.database.orm.parser.statementbuilder.tablemodification.AlterTableBuilder
;
import
com.frostnerd.utils.database.orm.statementoptions.queryoptions.WhereCondition
;
import
com.frostnerd.utils.general.Utils
;
...
...
@@ -31,7 +32,7 @@ import java.util.Set;
*/
public
class
DatabaseHelper
extends
com
.
frostnerd
.
utils
.
database
.
DatabaseHelper
{
public
static
final
String
DATABASE_NAME
=
"data"
;
public
static
final
int
DATABASE_VERSION
=
3
;
public
static
final
int
DATABASE_VERSION
=
4
;
@NonNull
public
static
final
Set
<
Class
<?
extends
Entity
>>
entities
=
new
HashSet
<
Class
<?
extends
Entity
>>(){{
add
(
DNSEntry
.
class
);
...
...
@@ -40,6 +41,7 @@ public class DatabaseHelper extends com.frostnerd.utils.database.DatabaseHelper
add
(
DNSRuleImport
.
class
);
add
(
IPPortPair
.
class
);
add
(
Shortcut
.
class
);
add
(
DNSTLSConfiguration
.
class
);
}};
@Nullable
private
static
DatabaseHelper
instance
;
...
...
@@ -71,6 +73,7 @@ public class DatabaseHelper extends com.frostnerd.utils.database.DatabaseHelper
@Override
public
void
onBeforeUpgrade
(
SQLiteDatabase
db
,
int
oldVersion
,
int
newVersion
)
{
System
.
out
.
println
(
"Updating from "
+
oldVersion
+
" to "
+
newVersion
);
if
(
oldVersion
<=
1
){
List
<
Shortcut
>
shortcuts
=
new
ArrayList
<>();
List
<
DNSEntry
>
entries
=
new
ArrayList
<>();
...
...
@@ -113,6 +116,13 @@ public class DatabaseHelper extends com.frostnerd.utils.database.DatabaseHelper
onCreate
(
db
);
for
(
DNSEntry
entry:
entries
)
insert
(
entry
);
for
(
Shortcut
shortcut:
shortcuts
)
createShortcut
(
shortcut
);
}
else
if
(
oldVersion
<=
3
)
{
getSQLHandler
(
DNSTLSConfiguration
.
class
).
createTable
(
db
);
AlterTableBuilder
builder
=
new
AlterTableBuilder
(
getTableName
(
DNSEntry
.
class
));
findColumn
(
DNSEntry
.
class
,
"tlsconfig"
).
createColumnStructure
(
builder
);
for
(
String
s:
builder
.
getStatements
()){
db
.
execSQL
(
s
);
}
}
}
...
...
app/src/main/java/com/frostnerd/dnschanger/database/entities/DNSEntry.java
View file @
8d321f6c
...
...
@@ -5,6 +5,7 @@ import android.support.annotation.Nullable;
import
com.frostnerd.dnschanger.database.serializers.IPPortSerializer
;
import
com.frostnerd.utils.database.orm.MultitonEntity
;
import
com.frostnerd.utils.database.orm.annotations.Default
;
import
com.frostnerd.utils.database.orm.annotations.Named
;
import
com.frostnerd.utils.database.orm.annotations.NotNull
;
import
com.frostnerd.utils.database.orm.annotations.RowID
;
...
...
@@ -55,6 +56,10 @@ public class DNSEntry extends MultitonEntity implements Comparable<DNSEntry>{
@Named
(
name
=
"customentry"
)
private
boolean
customEntry
;
@Nullable
@Named
(
name
=
"tlsconfig"
)
private
DNSTLSConfiguration
dnsTLSConfiguration
;
@Named
(
name
=
"id"
)
@RowID
private
long
ID
;
...
...
@@ -218,6 +223,19 @@ public class DNSEntry extends MultitonEntity implements Comparable<DNSEntry>{
return
!(
ip
==
null
||
ip
.
equals
(
""
))
&&
(
entryAddressMatches
(
ip
,
dns1
)
||
entryAddressMatches
(
ip
,
dns2
)
||
entryAddressMatches
(
ip
,
dns1V6
)
||
entryAddressMatches
(
ip
,
dns2V6
));
}
public
boolean
supportsDNSOverTLS
(){
return
dnsTLSConfiguration
!=
null
;
}
@Nullable
public
DNSTLSConfiguration
getDnsTLSConfiguration
()
{
return
dnsTLSConfiguration
;
}
public
void
setDnsTLSConfiguration
(
@Nullable
DNSTLSConfiguration
dnsTLSConfiguration
)
{
this
.
dnsTLSConfiguration
=
dnsTLSConfiguration
;
}
@Override
public
String
toString
()
{
return
"DNSEntry{"
+
...
...
app/src/main/java/com/frostnerd/dnschanger/database/entities/DNSTLSConfiguration.java
0 → 100644
View file @
8d321f6c
package
com.frostnerd.dnschanger.database.entities
;
import
com.frostnerd.utils.database.orm.MultitonEntity
;
import
com.frostnerd.utils.database.orm.annotations.Named
;
import
com.frostnerd.utils.database.orm.annotations.RowID
;
import
com.frostnerd.utils.database.orm.annotations.Table
;
import
lombok.NoArgsConstructor
;
/**
* Copyright Daniel Wolf 2017
* All rights reserved.
* Code may NOT be used without proper permission, neither in binary nor in source form.
* All redistributions of this software in source code must retain this copyright header
* All redistributions of this software in binary form must visibly inform users about usage of this software
* <p>
* development@frostnerd.com
*/
@NoArgsConstructor
@Table
(
name
=
"DNSTLSConfiguration"
)
public
class
DNSTLSConfiguration
extends
MultitonEntity
{
@Named
(
name
=
"id"
)
@RowID
private
long
ID
;
@Named
(
name
=
"port"
)
private
int
port
;
@Named
(
name
=
"host"
)
private
String
hostName
;
public
DNSTLSConfiguration
(
int
port
,
String
hostName
)
{
this
.
port
=
port
;
this
.
hostName
=
hostName
;
}
public
int
getPort
()
{
return
port
;
}
public
long
getID
()
{
return
ID
;
}
public
String
getHostName
()
{
return
hostName
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment