Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
Practical-Cryptdb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Zhaozhen
Practical-Cryptdb
Commits
5e31df9a
Commit
5e31df9a
authored
May 22, 2017
by
casualet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
able to use command line arguments
parent
f092bdec
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
25 deletions
+20
-25
mbk.cc
main/mbk.cc
+20
-25
No files found.
main/mbk.cc
View file @
5e31df9a
...
@@ -573,7 +573,13 @@ std::string getTestQuery(SchemaInfo &schema, std::vector<transField> &tfds,
...
@@ -573,7 +573,13 @@ std::string getTestQuery(SchemaInfo &schema, std::vector<transField> &tfds,
int
int
main
()
{
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
3
){
for
(
int
i
=
0
;
i
<
argc
;
i
++
){
printf
(
"%s
\n
"
,
argv
[
i
]);
}
return
0
;
}
gmp
[
SECLEVEL
::
INVALID
]
=
"INVALID"
;
gmp
[
SECLEVEL
::
INVALID
]
=
"INVALID"
;
gmp
[
SECLEVEL
::
PLAINVAL
]
=
"PLAINVAL"
;
gmp
[
SECLEVEL
::
PLAINVAL
]
=
"PLAINVAL"
;
gmp
[
SECLEVEL
::
OPE
]
=
"OPE"
;
gmp
[
SECLEVEL
::
OPE
]
=
"OPE"
;
...
@@ -596,31 +602,26 @@ main() {
...
@@ -596,31 +602,26 @@ main() {
clients
[
client
]
=
new
WrapperState
();
clients
[
client
]
=
new
WrapperState
();
//Connect phase
//Connect phase
ConnectionInfo
ci
(
"localhost"
,
"root"
,
"letmein"
,
3306
);
ConnectionInfo
ci
(
"localhost"
,
"root"
,
"letmein"
,
3306
);
//const std::string master_key = "113341234";
const
std
::
string
master_key
=
"113341234"
;
const
std
::
string
master_key
=
"113341234HEHE"
;
char
*
buffer
;
char
*
buffer
;
if
((
buffer
=
getcwd
(
NULL
,
0
))
==
NULL
){
if
((
buffer
=
getcwd
(
NULL
,
0
))
==
NULL
){
perror
(
"getcwd error"
);
perror
(
"getcwd error"
);
}
}
embeddedDir
=
std
::
string
(
buffer
)
+
"/shadow"
;
embeddedDir
=
std
::
string
(
buffer
)
+
"/shadow"
;
SharedProxyState
*
shared_ps
=
SharedProxyState
*
shared_ps
=
new
SharedProxyState
(
ci
,
embeddedDir
,
master_key
,
determineSecurityRating
());
new
SharedProxyState
(
ci
,
embeddedDir
,
master_key
,
determineSecurityRating
());
assert
(
0
==
mysql_thread_init
());
assert
(
0
==
mysql_thread_init
());
//we init embedded database here.
//we init embedded database here.
clients
[
client
]
->
ps
=
std
::
unique_ptr
<
ProxyState
>
(
new
ProxyState
(
*
shared_ps
));
clients
[
client
]
->
ps
=
std
::
unique_ptr
<
ProxyState
>
(
new
ProxyState
(
*
shared_ps
));
clients
[
client
]
->
ps
->
safeCreateEmbeddedTHD
();
clients
[
client
]
->
ps
->
safeCreateEmbeddedTHD
();
//Connect end!!
//Connect end!!
globalConn
=
new
Connect
(
ci
.
server
,
ci
.
user
,
ci
.
passwd
,
ci
.
port
);
globalConn
=
new
Connect
(
ci
.
server
,
ci
.
user
,
ci
.
passwd
,
ci
.
port
);
std
::
string
curQuery
=
"SHOW DATABASES;"
;
//-------------------------finish connection---------------------------------------
std
::
cout
<<
"please input a new query:######################################################"
<<
std
::
endl
;
std
::
getline
(
std
::
cin
,
curQuery
)
;
std
::
string
curQuery
=
"backpart"
;
//unsigned long long _thread_id = globalConn->get_thread_id();
//unsigned long long _thread_id = globalConn->get_thread_id();
while
(
curQuery
!=
"quit"
){
if
(
curQuery
!=
"quit"
){
if
(
curQuery
.
size
()
==
0
){
std
::
cout
<<
std
::
endl
;
std
::
getline
(
std
::
cin
,
curQuery
);
continue
;
}
if
(
curQuery
==
"test"
){
if
(
curQuery
==
"test"
){
std
::
string
db
,
table
;
std
::
string
db
,
table
;
std
::
cout
<<
"please input dbname "
<<
std
::
endl
;
std
::
cout
<<
"please input dbname "
<<
std
::
endl
;
...
@@ -637,7 +638,6 @@ main() {
...
@@ -637,7 +638,6 @@ main() {
std
::
shared_ptr
<
ReturnMeta
>
rm
=
getReturnMeta
(
fms
,
res
);
std
::
shared_ptr
<
ReturnMeta
>
rm
=
getReturnMeta
(
fms
,
res
);
std
::
string
backq
=
getTestQuery
(
*
schema
,
res
,
db
,
table
);
std
::
string
backq
=
getTestQuery
(
*
schema
,
res
,
db
,
table
);
rawReturnValue
resraw
=
executeAndGetResultRemote
(
globalConn
,
backq
);
rawReturnValue
resraw
=
executeAndGetResultRemote
(
globalConn
,
backq
);
//printrawReturnValue(resraw);
ResType
rawtorestype
=
MygetResTypeFromLuaTable
(
false
,
&
resraw
);
ResType
rawtorestype
=
MygetResTypeFromLuaTable
(
false
,
&
resraw
);
auto
finalresults
=
decryptResults
(
rawtorestype
,
*
rm
);
auto
finalresults
=
decryptResults
(
rawtorestype
,
*
rm
);
parseResType
(
finalresults
);
parseResType
(
finalresults
);
...
@@ -651,12 +651,12 @@ main() {
...
@@ -651,12 +651,12 @@ main() {
//get all the fields in the tables.
//get all the fields in the tables.
std
::
vector
<
FieldMeta
*>
fms
=
getFieldMeta
(
*
schema
,
db
,
table
);
std
::
vector
<
FieldMeta
*>
fms
=
getFieldMeta
(
*
schema
,
db
,
table
);
auto
res
=
getTransField
(
fms
);
auto
res
=
getTransField
(
fms
);
//for each filed, we choose all the onions and salts.
//for each filed, we choose all the onions and salts.
for
(
auto
&
item
:
res
){
for
(
auto
&
item
:
res
){
assert
(
item
.
choosenOnions
.
size
()
==
0u
);
assert
(
item
.
choosenOnions
.
size
()
==
0u
);
assert
(
item
.
onions
.
size
()
==
item
.
originalOm
.
size
());
assert
(
item
.
onions
.
size
()
==
item
.
originalOm
.
size
());
assert
(
item
.
fields
.
size
()
==
item
.
originalOm
.
size
()
||
item
.
fields
.
size
()
==
item
.
originalOm
.
size
()
+
1
);
assert
(
item
.
fields
.
size
()
==
item
.
originalOm
.
size
()
||
item
.
fields
.
size
()
==
item
.
originalOm
.
size
()
+
1
);
for
(
unsigned
int
i
=
0u
;
i
<
item
.
onions
.
size
();
i
++
)
{
for
(
unsigned
int
i
=
0u
;
i
<
item
.
onions
.
size
();
i
++
)
{
item
.
choosenOnions
.
push_back
(
i
);
item
.
choosenOnions
.
push_back
(
i
);
}
}
...
@@ -666,21 +666,18 @@ main() {
...
@@ -666,21 +666,18 @@ main() {
rawReturnValue
resraw
=
executeAndGetResultRemote
(
globalConn
,
backq
);
rawReturnValue
resraw
=
executeAndGetResultRemote
(
globalConn
,
backq
);
getInsertQuery
(
*
schema
,
res
,
db
,
table
,
resraw
);
getInsertQuery
(
*
schema
,
res
,
db
,
table
,
resraw
);
}
else
if
(
curQuery
==
"backpart"
){
}
else
if
(
curQuery
==
"backpart"
){
std
::
string
db
,
table
;
std
::
string
db
(
argv
[
1
]),
table
(
argv
[
2
]);
std
::
cout
<<
"please input dbname "
<<
std
::
endl
;
std
::
cout
<<
db
<<
":"
<<
table
<<
std
::
endl
;
cin
>>
db
;
std
::
cout
<<
"please input table name "
<<
std
::
endl
;
cin
>>
table
;
std
::
unique_ptr
<
SchemaInfo
>
schema
=
myLoadSchemaInfo
();
std
::
unique_ptr
<
SchemaInfo
>
schema
=
myLoadSchemaInfo
();
//get all the fields in the tables.
//get all the fields in the tables.
std
::
vector
<
FieldMeta
*>
fms
=
getFieldMeta
(
*
schema
,
db
,
table
);
std
::
vector
<
FieldMeta
*>
fms
=
getFieldMeta
(
*
schema
,
db
,
table
);
auto
res
=
getTransField
(
fms
);
auto
res
=
getTransField
(
fms
);
//for each filed, we choose all the onions and salts.
//for each filed, we choose all the onions and salts.
for
(
auto
&
item
:
res
){
for
(
auto
&
item
:
res
){
assert
(
item
.
choosenOnions
.
size
()
==
0u
);
assert
(
item
.
choosenOnions
.
size
()
==
0u
);
assert
(
item
.
onions
.
size
()
==
item
.
originalOm
.
size
());
assert
(
item
.
onions
.
size
()
==
item
.
originalOm
.
size
());
assert
(
item
.
fields
.
size
()
==
item
.
originalOm
.
size
()
||
item
.
fields
.
size
()
==
item
.
originalOm
.
size
()
+
1
);
assert
(
item
.
fields
.
size
()
==
item
.
originalOm
.
size
()
||
item
.
fields
.
size
()
==
item
.
originalOm
.
size
()
+
1
);
item
.
choosenOnions
.
push_back
(
0
);
item
.
choosenOnions
.
push_back
(
0
);
}
}
std
::
string
backq
=
getBackupQuery
(
*
schema
,
res
,
db
,
table
);
std
::
string
backq
=
getBackupQuery
(
*
schema
,
res
,
db
,
table
);
...
@@ -688,8 +685,6 @@ main() {
...
@@ -688,8 +685,6 @@ main() {
rawReturnValue
resraw
=
executeAndGetResultRemote
(
globalConn
,
backq
);
rawReturnValue
resraw
=
executeAndGetResultRemote
(
globalConn
,
backq
);
getInsertQuery
(
*
schema
,
res
,
db
,
table
,
resraw
);
getInsertQuery
(
*
schema
,
res
,
db
,
table
,
resraw
);
}
}
std
::
cout
<<
GREEN_BEGIN
<<
"
\n
please input a new query:#######"
<<
COLOR_END
<<
std
::
endl
;
std
::
getline
(
std
::
cin
,
curQuery
);
}
}
return
0
;
return
0
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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