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
Show 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,
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
::
PLAINVAL
]
=
"PLAINVAL"
;
gmp
[
SECLEVEL
::
OPE
]
=
"OPE"
;
...
...
@@ -596,31 +602,26 @@ main() {
clients
[
client
]
=
new
WrapperState
();
//Connect phase
ConnectionInfo
ci
(
"localhost"
,
"root"
,
"letmein"
,
3306
);
//const std::string master_key = "113341234";
const
std
::
string
master_key
=
"113341234HEHE"
;
const
std
::
string
master_key
=
"113341234"
;
char
*
buffer
;
if
((
buffer
=
getcwd
(
NULL
,
0
))
==
NULL
){
perror
(
"getcwd error"
);
}
embeddedDir
=
std
::
string
(
buffer
)
+
"/shadow"
;
SharedProxyState
*
shared_ps
=
new
SharedProxyState
(
ci
,
embeddedDir
,
master_key
,
determineSecurityRating
());
new
SharedProxyState
(
ci
,
embeddedDir
,
master_key
,
determineSecurityRating
());
assert
(
0
==
mysql_thread_init
());
//we init embedded database here.
clients
[
client
]
->
ps
=
std
::
unique_ptr
<
ProxyState
>
(
new
ProxyState
(
*
shared_ps
));
clients
[
client
]
->
ps
->
safeCreateEmbeddedTHD
();
//Connect end!!
globalConn
=
new
Connect
(
ci
.
server
,
ci
.
user
,
ci
.
passwd
,
ci
.
port
);
std
::
string
curQuery
=
"SHOW DATABASES;"
;
std
::
cout
<<
"please input a new query:######################################################"
<<
std
::
endl
;
std
::
getline
(
std
::
cin
,
curQuery
)
;
//-------------------------finish connection---------------------------------------
std
::
string
curQuery
=
"backpart"
;
//unsigned long long _thread_id = globalConn->get_thread_id();
while
(
curQuery
!=
"quit"
){
if
(
curQuery
.
size
()
==
0
){
std
::
cout
<<
std
::
endl
;
std
::
getline
(
std
::
cin
,
curQuery
);
continue
;
}
if
(
curQuery
!=
"quit"
){
if
(
curQuery
==
"test"
){
std
::
string
db
,
table
;
std
::
cout
<<
"please input dbname "
<<
std
::
endl
;
...
...
@@ -637,7 +638,6 @@ main() {
std
::
shared_ptr
<
ReturnMeta
>
rm
=
getReturnMeta
(
fms
,
res
);
std
::
string
backq
=
getTestQuery
(
*
schema
,
res
,
db
,
table
);
rawReturnValue
resraw
=
executeAndGetResultRemote
(
globalConn
,
backq
);
//printrawReturnValue(resraw);
ResType
rawtorestype
=
MygetResTypeFromLuaTable
(
false
,
&
resraw
);
auto
finalresults
=
decryptResults
(
rawtorestype
,
*
rm
);
parseResType
(
finalresults
);
...
...
@@ -651,12 +651,12 @@ main() {
//get all the fields in the tables.
std
::
vector
<
FieldMeta
*>
fms
=
getFieldMeta
(
*
schema
,
db
,
table
);
auto
res
=
getTransField
(
fms
);
//for each filed, we choose all the onions and salts.
for
(
auto
&
item
:
res
){
assert
(
item
.
choosenOnions
.
size
()
==
0u
);
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
++
)
{
item
.
choosenOnions
.
push_back
(
i
);
}
...
...
@@ -666,21 +666,18 @@ main() {
rawReturnValue
resraw
=
executeAndGetResultRemote
(
globalConn
,
backq
);
getInsertQuery
(
*
schema
,
res
,
db
,
table
,
resraw
);
}
else
if
(
curQuery
==
"backpart"
){
std
::
string
db
,
table
;
std
::
cout
<<
"please input dbname "
<<
std
::
endl
;
cin
>>
db
;
std
::
cout
<<
"please input table name "
<<
std
::
endl
;
cin
>>
table
;
std
::
string
db
(
argv
[
1
]),
table
(
argv
[
2
]);
std
::
cout
<<
db
<<
":"
<<
table
<<
std
::
endl
;
std
::
unique_ptr
<
SchemaInfo
>
schema
=
myLoadSchemaInfo
();
//get all the fields in the tables.
std
::
vector
<
FieldMeta
*>
fms
=
getFieldMeta
(
*
schema
,
db
,
table
);
auto
res
=
getTransField
(
fms
);
//for each filed, we choose all the onions and salts.
for
(
auto
&
item
:
res
){
assert
(
item
.
choosenOnions
.
size
()
==
0u
);
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
);
}
std
::
string
backq
=
getBackupQuery
(
*
schema
,
res
,
db
,
table
);
...
...
@@ -688,8 +685,6 @@ main() {
rawReturnValue
resraw
=
executeAndGetResultRemote
(
globalConn
,
backq
);
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
;
}
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